vb.net 什么是 c# 中的 vbNullChar 等价物?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15360914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what is a vbNullChar equivalent in c#?
提问by Neeraj Kumar Gupta
What is a equivalent of Visual basic 'vbNullChar" in c# ?
c# 中 Visual basic 'vbNullChar' 的等价物是什么?
i want to replicate this VB statement in C#
我想在 C# 中复制这个 VB 语句
Dim sVersion As String
sVersion = New String(vbNullChar, 255)
回答by Jon Skeet
I suspect you want:
我怀疑你想要:
string sVersion = new string('char vbNullChar = Convert.ToChar(0);//C# Equivalent to vbNullChar
string sVersion = new string(vbNullChar, 255);
', 255);
(This seems like an odd thing to want to do though. I would try taking a step back and seeing whether there isn't a more appropriate approach to the bigger problem.)
(虽然这似乎是一件奇怪的事情。我会尝试退后一步,看看是否有更合适的方法来解决更大的问题。)
回答by Pandian
Jon Skeet is correct...
乔恩斯基特是对的......
Also you can achieve this thing by below method...
您也可以通过以下方法实现此目的...
1st Way
第一种方式
char vbNullChar = Convert.ToChar(0x0);//C# Equivalent to vbNullChar
string sVersion = new string(vbNullChar, 255);
2nd Way
第二种方式
##代码##
