[英]C# String Length
Why are those two string returning different values for length. 为什么这两个字符串返回不同的长度值。 "CertificateKey" is a property.
“CertificateKey”是一个属性。 It returns 41 for length.
它的长度为41。 However, the equivalent constant string returns 40. If I copy the value of certificate as a constant, the length returns 41. Why?!?
但是,等效常量字符串返回40.如果我将证书的值复制为常量,则长度返回41.为什么?!?
// This is the property. Length 41
CertificateKey.Length
41 41
// This is a constant of the same string. Length 40
"9FE90CA8A4138F65E9E2C67D1F37B9D5B9919384".Length
40 40
// This is a copy of the value of the property above. Length 41
"9FE90CA8A4138F65E9E2C67D1F37B9D5B9919384".Length
41 41
I copied and pasted your two string literals into LINQPad and found that I could reproduce your result, so then I printed each character like so: 我将你的两个字符串文字复制并粘贴到LINQPad中 ,发现我可以重现你的结果,然后我就像这样打印每个字符:
var a = "9FE90CA8A4138F65E9E2C67D1F37B9D5B9919384";
var b = "9FE90CA8A4138F65E9E2C67D1F37B9D5B9919384";
foreach (char c in a) Console.WriteLine($"{(int)c:X}");
Console.WriteLine("---");
foreach (char c in b) Console.WriteLine($"{(int)c:X}");
And got the following result: 得到以下结果:
39
46
[...]
34
---
200E
39
46
[...]
34
200E
is the left-to-right mark . 200E
是从左到右的标记 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.