|
The VB string members having direct .NET equivalents include Asc,
Chr, Format, GetChar, InStr, LCase, Left, Len, LTrim, Mid, Replace,
Right, RTrim, Space, Split, StrComp, Trim, and UCase. Try the
Demo Edition of Instant C#
for details. In general, you need to be aware that the VB
methods usually yield 1-based results, or expect 1-based arguments,
while the .NET methods are always 0-based.
For example, the following VB code:
y
= Mid(y, 3)
Can be converted to the following C# code:
y
= y.Substring(2);
Overview of VB to .NET string method mappings:
-
LCase and UCase convert to ToLower and ToUpper
-
Left, Mid, and Right convert to Substring
-
LTrim, RTrim, and Trim convert to TrimStart, TrimEnd, and Trim
-
InStr converts to IndexOf
-
Len converts to Length
-
Replace converts to Replace
If you need to convert from VB.NET to C# and
you are depending on the results being reliable and accurate, then
you will want to have
Instant C#,
the best VB.NET to C# converter, at your fingertips.
|