Programming Tutorials

How to use string chars (str.Chars() ) in VB.net

By: Issac in VB.net Tutorials on 2009-01-30  

In VB.net, the Chars() method of a string returns a character at a specified index. The index is zero-based, meaning that the first character in the string has an index of 0, the second character has an index of 1, and so on. Here's an example of how to use the Chars() method in VB.net:

Dim str As String = "Hello, world!"
Dim ch As Char = str.Chars(1) ' Returns the character at index 1 (i.e., 'e')

In this example, we create a string variable called str and assign it the value "Hello, world!". We then call the Chars() method of the string and pass in the index 1 to get the second character in the string, which is 'e'. The resulting character is assigned to a Char variable called ch.






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in VB.net )

Latest Articles (in VB.net)