如何像在 php 中一样从数组中获取数据?
$arr = array(
'123' => 'abc',
'456' => 'def'
);
echo $arr['123']; // abc
我如何在 C# 中对数组做同样的事情?
最佳答案
这看起来像一个 dictionary :
Dictionary<int, string> dict = new Dictionary<int, string>
{
{123, "abc"}, {456, "def"}
};
Console.WriteLine(dict[123]); // abc
关于C# 以与我在 php 中相同的方式从数组中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38247301/