title: C# - How can i color string if they start and end with the same number
body: <p>As mentioned above i need to have a part of my string colored if they start and end with the same number.
  Im a beginner and can't really figure it out, i have googled but haven't found any answers.</p>
  <p><em>EDIT</em>
  To clarify, i need to print the whole string and not just the colored part.</p>
  <pre><code>string userInput = &quot;29535123p48723487597645723645&quot;;
              //Console.WriteLine(userInput);
              
              for (int i = 0; i &lt; userInput.Length; i++)
              {
                  if (Char.IsDigit(userInput[i]))
                  {
                      for (int j = i + 1; j &lt; userInput.Length; j++)
                      {
                          if (userInput[i] == userInput[j])
                          {
                              Console.ForegroundColor = ConsoleColor.Green;
                              Console.WriteLine(userInput.Substring(i, j - i + 1));
                              break;
                          }
                          else if (!Char.IsDigit(userInput[j]))
                          {
  
                              break;
                          }
                      }
                  }
  
              }
              Console.ReadKey();
  </code></pre>