J'ai un tableau de chaînes:C# clés du tableau de style PHP
String[] array1 = new String[10];
Y at-il de toute façon je peux utiliser les touches qui sont des nombres NTO?
array["keyhere"] instead of array1[1]
quelqu'un sait comment?
J'ai un tableau de chaînes:C# clés du tableau de style PHP
String[] array1 = new String[10];
Y at-il de toute façon je peux utiliser les touches qui sont des nombres NTO?
array["keyhere"] instead of array1[1]
quelqu'un sait comment?
Utilisez System.Collections.Generic.Dictionary<TKey, TValue>
.
Par exemple:
Dictionary<string, string> myDictionary = new Dictionary<string, string>();
myDictionary.Add("key", "value");
string foo = myDictionary["key"];
Dictionary<TKey, TValue>
a quelques méthodes qui pourraient vous être utiles, comme ContainsKey()
.
Utilisez un dictionnaire
Dictionary<String,Object> phpArray = new Dictionary<String,Object>();
phpArray.Add("keyhere",1);
MessageBox.Show(phpArray["keyhere"]);
tableaux PHP sont appelés tableaux associatifs. Vous pouvez utiliser un dictionnaire ou HashMap pour implémenter la même chose en C#.