Position of character to the left of current position in string

c#, indexing, string

Solution

What about:

yourstring.LastIndexOf("foo", 0, currentPosition)                                  

Problem

From some arbitrary position in a string I need to find the closest position of a character to the left of my position. If I want to perform this operation to the right I could just use `.IndexOf`, but how to do it to the left I am unsure. The two ways I came up with were just a decrementing loop starting at my position or, putting the string in reverse and using a normal `.IndexOf` Anyone else have any better ways of achieving this?

Original source