C N*_*C N 8 c# string ascii contains
在C#中,如何使用该String.Contains函数查找字符串是否有回车符?回车的ascii是13.
Chr(13)是如何在Visual Basic中表示回车.如何使用其ascii字符在C#中表示回车符而不是"\r"?
if (word.Contains(Chr(13))
{
.
.
.
}
Run Code Online (Sandbox Code Playgroud)
Mar*_*ers 16
既然你声明你不想使用\r那么你可以将整数转换为char:
if (word.Contains((char)13)) { ... }
Run Code Online (Sandbox Code Playgroud)
Joa*_*oao 15
if (word.Contains(Environment.NewLine)) { }
Run Code Online (Sandbox Code Playgroud)
您可以char使用单引号输入值
var s = "hello\r";
if (s.Contains('\r'))
{
}
Run Code Online (Sandbox Code Playgroud)
如果它更容易阅读,你可以转换13为char
var s = "hello\r";
if (s.Contains((char)13))
{
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
38285 次 |
| 最近记录: |