+92 332 4229 857 99ProjectIdeas@Gmail.com

String.StartsWith function (Vb.net)


String StartsWith function
String.StartsWith() function is used to check whether the specified string starts on your desired input character or not.
System.String is the library for this function.
 
Example1
Dim str1 As String = "Saad Bin Saulat"
MsgBox(str1.StartsWith("S"))
Result
The message box will returns true because the string str1 is starting from capital "s".

Example2
Dim str1 As String = "Saad Bin Saulat"
MsgBox(str1.StartsWith("s"))
Result
The message box will returns false because the string str1 is not starting from small "s", hence starting from capital "S".

Example3
Dim str1 As String = "Saad Bin Saulat"
MsgBox(str1.StartsWith("s", StringComparison.InvariantCultureIgnoreCase))
Result
The message box will returns true because the due to StringComparison.InvariantCultureIgnoreCase parameter, StartsWith() function now only checks the letter not the case.


Related articles

0 comments: