我有一个 n×3 数组,我希望转换为 a Dictionary<string,string[]>
,其中第一列是键,列的其余部分作为值的数组。
例如:
Key = arr[0,0], Value = new string[2] {arr[0,1], arr[0,2]}.
Run Code Online (Sandbox Code Playgroud)
我知道ToDictionary
但我不知道如何设置值部分。
arr.ToDictionary(x=>arr[x,0],x=>new string[2]{arr[x,1],arr[x,2]});
//This doesn't work!!!
Run Code Online (Sandbox Code Playgroud)
我该如何正确设置?
我有一个string
由汉字和可显示的ASCII码混合而成的.
string str = "Test??123";
Run Code Online (Sandbox Code Playgroud)
当我使用str.Length
或者str.ToCharArray()
,它们都将每个汉字作为1个字符返回!这不是真的,因为任何中文字符都是2字节!
即使我尝试Encoding.ASCII.GetBytes(str)
,它只给我63英寸的所有汉字!结果与结果相同Length
或者ToCharArray()
!
哪个是我的目的错误的结果!
有没有办法得到一个字符串的实际长度!?
在我给出的例子中:11而不是9!?
我阅读了Nullable Structure并了解其中的大部分内容.但我不知道人们何时以及为何会使用它.
c# ×3
arrays ×1
ascii ×1
dictionary ×1
nullable ×1
size ×1
string ×1
structure ×1
todictionary ×1