VBScript to C# - Equivalent string functions

A Cheat Sheet containing the VBScript string functions and their equivalent methods in C#.

VBScript
Description
C# Equivalent
InStr Returns the position of the first occurrence of one string within another. The search begins at the first character of the string IndexOf()
InStrRev Returns the position of the first occurrence of one string within another. The search begins at the last character of the string -
LCase Converts a specified string to lowercase ToLower()
Left Returns a specified number of characters from the left side of a string SubString()
Len Returns the number of characters in a string Length()
LTrim Removes spaces on the left side of a string TrimStart()
RTrim Removes spaces on the right side of a string TrimEnd()
Trim Removes spaces on both the left and the right side of a string Trim()
Mid Returns a specified number of characters from a string SubString()
Replace Replaces a specified part of a string with another string a specified number of times Replace()
Right Returns a specified number of characters from the right side of a string SubString()
Space Returns a string that consists of a specified number of spaces PadLeft(), PadRight()
StrComp Compares two strings and returns a value that represents the result of the comparison Compare(), Equals()
String Returns a string that contains a repeating character of a specified length -
StrReverse Reverses a string -
UCase Converts a specified string to uppercase ToUpper()

Date Posted:
Last Updated:
Posted by:
Total Views to date: 20482

1 Comment

- Gary Winey

Hello,

String - Returns a string that contains a repeating character of a specified length - new string('0', 10)

One of the overloaded string constructors takes a char and repeats it x number of times.

Thanks for sharing your expertise with others!

Recent Comments

Manie Verster 5/28/2015 9:39 AM
In response to MVC 5 with EF 6 in Visual Basic - Implementing Inheritance
Sorry Mike but on my project when run it does not show the hire date and/or enrollment date. I the I...

Joseph Casey 5/27/2015 3:17 PM
In response to ASP.NET MVC 5 with EF 6 - Working With Files
Probably should have read the title. Couldn't use it with Visual Studios 2013. =[...

jean 5/27/2015 8:41 AM
In response to iTextSharp - Drawing shapes and Graphics
hey Mike, I read your arcticle about drawing on PDF with ITextSharp, it was really interesting !...

Alexandros L 5/26/2015 10:50 PM
In response to Entity Framework 6 Recipe - Hierarchical Data Management
You are a live saver.. thank you so much......

saurabh rao 5/26/2015 1:03 PM
In response to ASP.NET MVC 5 with EF 6 - Working With Files
Hey Mike ! Great article ...the code worked flawlessly for me. Didn't have any issues executing it ....

Vijay 5/25/2015 2:12 PM
In response to How To Send Email In ASP.NET MVC
Thanks...

RR 5/25/2015 8:58 AM
In response to Web Pages - Efficient Paging Without The WebGrid
@MIke.. is it possible to combine pagination and filter (change category ) in the script? Thanks...

Irfan Khan 5/25/2015 6:19 AM
In response to Highlighting Keywords Found In Search Results
This is truely helpful. Thank you for the brilliant tip....

Manoj Kulkarni 5/25/2015 4:46 AM
In response to Custom TagHelpers in ASP.NET MVC 6
Thank you for nice article. Really helpful....

Sean 5/21/2015 4:20 AM
In response to ASP.NET MVC 5 with EF 6 - Working With Files
Thank you for the tutorial. Saving to the database works, but the save FilePath is not working. It...