Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Substring()在&;处停止字符串;象征_C#_String_Substring - Fatal编程技术网

C#Substring()在&;处停止字符串;象征

C#Substring()在&;处停止字符串;象征,c#,string,substring,C#,String,Substring,C#Substring()不起作用,它在&symbol之前停止: var name = "my_company_&_friends"; var sub = name.Substring(2); // sub should be all string starting with symbol index 2 // sub should be "_company_&_friends" // but it is "_company_" 这是虫子吗?如何修复它?这正是您所期望的 在此

C#Substring()不起作用,它在&symbol之前停止:

var name = "my_company_&_friends";
var sub = name.Substring(2);
// sub should be all string starting with symbol index 2
// sub should be "_company_&_friends"
// but it is "_company_"

这是虫子吗?如何修复它?

这正是您所期望的

在此之后您所做的可能会导致问题。

您这边的问题。 关于我的系统

如何显示
sub
?我刚刚在控制台应用程序中运行了该代码以及
控制台.WriteLine()
,结果看起来很好。我的心理调试技能告诉我,你正在将其渲染为HTML,而忘记了转义。不,无法复制它。问题不在于我的心理调试技能与
SLaks
的一致,因为给出的代码工作得很好,但是将其输出为HTML确实会显示
\u company