top of page

How to find a chr and its position in a String

It is easy to find a the position of a chr in another string using the below function.

 

public static int Findstring(string input, string chrtolook)

{

//find the first / in the path string

int ret = 0;

for (int i = input.Length - 1; i >= 0; i--)

{

if (input.Substring(i, 1) == chrtolook)

{ ret = i + 1; break;

}

}

return ret;

}

Please reload

bottom of page