What is the vbNullChar equivalent in C #?

What is the Visual Basic equivalent of 'vbNullChar' in C #?

I want to replicate this VB statement in C #

Dim sVersion As String
sVersion = New String(vbNullChar, 255)
+5
source share
2 answers

I suspect you want:

string sVersion = new string('\0', 255);

(This seems like a strange thing that I want to do, although I would try to take a step back and see if there is a more suitable approach to the bigger problem.)

+15
source

John Skeet is right ...

Also you can achieve this thing below method ...

1st way

char vbNullChar = Convert.ToChar(0);//C# Equivalent to vbNullChar
string sVersion = new string(vbNullChar, 255);

2nd way

char vbNullChar = Convert.ToChar(0x0);//C# Equivalent to vbNullChar
string sVersion = new string(vbNullChar, 255);
+3
source

All Articles