Programming Tutorials

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

By: Issac in Tutorials on 2009-01-30  

In, 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

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


No comments yet. Be the first!

Most Viewed Articles (in )

Latest Articles (in