Warm tip: This article is reproduced from stackoverflow.com, please click
c# vb6

String(33, 0) in VB 6.0 and equivalent in C#

发布于 2020-04-19 09:39:51

What is the meaning of UserName = String(33, 0) in VB 6.0 and what will be the equivalent in C#.

Please help I'm getting error while converting VB 6.0 code into C#.

Thanks in advance.

Questioner
apratik
Viewed
37
linepogl 2013-07-25 19:10

String in VB6 is a function that returns a string containing a repeating character string of the length specified.

String(number,character)

example:

strTest = String(5, "a")
' strTest = "aaaaa"

strTest = String(5, 97)
' strTest = "aaaaa" (97 is the ASCII code for "a")

In this case, String(33,0) will return a string containing 33 null characters.

The equivalent in C# would be

UserName = new String('\0', 33);