相当于Chr(34) [英] Chr(34) equivalent
问题描述
我正在将 VB.NET
代码转换为 c#
,当我到达以下代码段时,我就停了下来.我需要某人的帮助来转换Chr(34).请帮助我将其转换为 c#
.
I am converting VB.NET
code to c#
and I am stopped when I reached the following code snippet. I need someone's help to convert Chr(34). Please help me to convert it to c#
.
VB.NET代码
Dim inputString As String
inputString = "Some text ..."
inputString = Replace(inputString, Chr(34), "")**
我的c#转换是
string inputString = "Some text ...";
inputString = inputString.Replace(NEED HELP HERE, "");**
推荐答案
您可以将整数转换为 char
,因此自动"翻译为:
You can cast an integer to a char
, so an "automatic" translation would be:
inputString = inputString.Replace(, ((char) 34).ToString(), "")
话虽这么说,映射到34(根据ASCII)的字符是"
,所以您可以简单地用双引号char构造一个字符串:
That being said, the characters that maps to 34 (according to ASCII) is "
, so you can simply construct a string with the double quote char:
inputString = inputString.Replace(, "\"", "")
这也将提高可读性,因为现在可以清楚地知道该部分的工作:删除双引号字符.
This will also improve readability, since it is now clear what you are doing in that part: you remove double quotation characters.
这篇关于相当于Chr(34)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!