Reputation: 753
how can get data from array in same way like i can in php?
$arr = array(
'123' => 'abc',
'456' => 'def'
);
echo $arr['123']; // abc
How can i do same with array's at C#?
Upvotes: 2
Views: 71
Reputation: 460168
That looks like a dictionary:
Dictionary<int, string> dict = new Dictionary<int, string>
{
{123, "abc"}, {456, "def"}
};
Console.WriteLine(dict[123]); // abc
Upvotes: 5