SoFunction
Updated on 2025-03-06

C# How to find out the first letter in a string and capitalize it

This article describes the method of C# to find the first letter in a string and capitalize it. Share it for your reference, as follows:

class Program
{
  static void Main(string[] args)
  {
   String aa = "%.,46,2xb1bfs.,,";
   int pos = isLetter(aa);
   aa = (pos, 1);
   (());
   ();
  }
  public static int isLetter(string validString)
  {
   byte[] tempbyte = (validString);
   int pos = 0;
   for (int i = 0; i < ; i++)
   {
    byte by = tempbyte[i];
    if ((by >= 65) && (by <= 90) || ((by >= 97) && (by <= 122)))
    {
     break;
    }
    pos++;
   }
   return pos;
  }
}

For more information about C# related content, please check out the topic of this site:C# data structure and algorithm tutorial"and"Summary of C# string operation skills

I hope this article will be helpful to everyone's C# programming.