using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class test2 : MonoBehaviour
{
string str = "error=0&result=1&hello=2";
// Use this for initialization
void Start ()
{
parse();
}
// Update is called once per frame
void Update ()
{
}
void parse()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
string[] sArray = str.Split('&');
foreach(var i in sArray)
{
Debug.Log(i);
string[] subArray = i.Split('=');
int index = i.IndexOf('=');
dic.Add(i.Substring(0, index), i.Substring(index + 1, i.Length - index - 1));
}
foreach(var i in dic)
{
Debug.Log(string.Format("key : {0}, value : {1}", i.Key, i.Value));
}
}
}
c#解析 "error=0&result=1&hello=2"
最新推荐文章于 2022-02-22 10:57:24 发布