Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is a vbNullChar equivalent in c#?

Tags:

c#

vb.net

What is a equivalent of Visual basic 'vbNullChar" in c# ?

i want to replicate this VB statement in C#

Dim sVersion As String
sVersion = New String(vbNullChar, 255)
like image 861
Neeraj Kumar Gupta Avatar asked Mar 12 '13 12:03

Neeraj Kumar Gupta


2 Answers

I suspect you want:

string sVersion = new string('\0', 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.)

like image 138
Jon Skeet Avatar answered Nov 17 '22 09:11

Jon Skeet


Jon Skeet is correct...

Also you can achieve this thing by 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);
like image 4
Pandian Avatar answered Nov 17 '22 10:11

Pandian