I was wondering how I can convert this PHP code to C#:
array("id" => $intID, "clients" => array(), "max" => $max, "requests" => 0);
In C# I have this:
string[,] waddleObject = new string[,]
{
{ "ID", ID.ToString() },
{ "clients", new string[] { } },
{ "max", max.ToString() },
{ "requests", "0" }
};
That C# doesn't work, any ideas what I can do here?
You can use the Dictionary which is available in C# like this.
Dictionary<string,List<string>> waddleObject = new Dictionary<string,List<string>>();
var item = new List<string>.Add(Id.ToString();
waddleObject.Add("Id",item);
The reason is that you can find the key in O(1). Like this
List<string> val = waddleObject["Id"];
You can use the Dictionary<int, List<string>>
:
Dictionary<int, List<string>> dictionary = new Dictionary<int, List<string>>();
dictionary.Add(ID, new List<string> { max, request });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.