I A Khan
I A Khan

Reputation: 8841

How to get particular character position from string using C#

This is very basic question but I am not able to find the position of a particular character. For example:

string a = "ABCDE"; 

I want the position of "E" from above string.

Upvotes: 6

Views: 41741

Answers (1)

nphx
nphx

Reputation: 1427

Use IndexOf

var pos = a.IndexOf('E');

Upvotes: 22

Related Questions