VB C#
UBound() = yourArray.GetUpperBound(0) or yourArray.Length for one-dimesional arrays
LBound() = yourArray.GetLowerBound(0)
IsNothing() = Object.ReferenceEquals(obj,null)
Chr() = Convert.ToChar()
Len() = "string".Length
UCase() = "string".ToUpper()
LCase() = "string".ToLower()
Left() = "string".Substring(0, length)
Right() = "string".Substring("string".Length - desiredLength)
RTrim() = "string".TrimEnd()
LTrim() = "string".TrimStart()
Trim() = "string".Trim()
Mid() = "string".Substring(start, length)
Replace() = "string".Replace()
Split() = "string".Split()
Join() = String.Join()
MsgBox() = MessageBox.Show()
IIF() = (boolean_condition ? "true" : "false")
Notes
yourArray.GetUpperBound(0)vsyourArray.Length: if the array is zero-length, GetUpperBound will return -1, while Length will return 0.UBound()in VB.NET will return -1 for zero-length arrays.- The VB string functions uses a one based index, while the .NET method uses a zero based index. I.e.
Mid("asdf",2,2)corresponds to"asdf".SubString(1,2). ?is not the exact equivalent ofIIfbecauseIIfalways evaluates both arguments, and?only evaluates the one it needs. This could matter if there are side effects of the evaluation ~ shudder!- The Many classic VB String functions, including
Len(),UCase(),LCase(),Right(),RTrim(), andTrim(), will treat an argument ofNothing(Nullin c#) as being equivalent to a zero-length string. Running string methods onNothingwill, of course, throw an exception. - You can also pass
Nothingto the classic VBMid()andReplace()functions. Instead of throwing an exception, these will returnNothing.