Question: How can I find all indexes of a pattern in a string using c#? 

For example I want to find all `##` pattern indexes in a string like this `45##78$$#56$$JK01UU`

Answer: 
```
 string pattern = "##";
 string sentence = "45##78$$#56$$J##K01UU";
 IList<int> indeces = new List<int>();
 foreach (Match match in Regex.Matches(sentence, pattern))
 {
      indeces.Add(match.Index);
 }

```

indeces will have 2, 14
Tested. Worked. But somewhat dumb.

```
string foo = "45##78$$#56$$JK01UU";
char[] fooChar = foo.ToCharArray();

int i = 0;
bool register = false;

foreach (char fc in fooChar)
{
    if (fc == '#' && register == true)
    {
        MessageBox.Show("Index: " + (i-1));
    }
    else if (fc == '#')
    {
        register = true;
    }
    else
    {
        register = false;
    }
    i++;
}

```