How to get char from index of string in c#

2043 views c#
5

in python you could write

string = "abcdef"
character = string[1]
print(character)

and your output would be

b

What would the c# equivalent be?

answered question

1 Answer

4

It is the same way in other languages as well,

string s = "abcdef";
char c = s[1];
Console.WriteLine(c);

Fiddle Example

posted this

Have an answer?

JD

Please login first before posting an answer.