Question: I am using the following to convert the first character of a string to upper and add a period at the end:

```
public static string toUpper (string mytext)
{
    if (string.IsNullOrEmpty(mytext) || mytext == "") return mytext;

    mytext = mytext.Trim();

    if (mytext.EndsWith("."))
    {
      mytext = mytext.First().ToString(CultureInfo.InvariantCulture).ToUpper()
             + string.Join("", mytext.Skip(1))
             ;
    }
    else
    {
      mytext = mytext.First().ToString(CultureInfo.InvariantCulture).ToUpper()
             + string.Join("", mytext.Skip(1))
             + "."
             ;
    }
    return mytext;
}

```

I get an error Sequence contains no elements if mytext = "" at this line:

```
 mytext = mytext.First().ToString(CultureInfo.InvariantCulture).ToUpper()
        + string.Join("", mytext.Skip(1))
        + "."
        ;

```

Would appreciate your suggestions.

Answer: 
After the Trim() method, you may have ended up with an empty string, which will cause an exception when you try to grab the first (non-existant) character.
your code has bugs . I modified it the following way 

```
public static string toUpper(string mytext)
        {
            if (String.IsNullOrWhiteSpace(mytext)) { return mytext; }

            mytext = mytext.Trim();

            if (mytext.EndsWith("."))
            {
                if (mytext.Length == 1)
                {
                    return mytext;
                }
                else
                {
                    string first = mytext.First();
                    mytext = String.Join(first.ToUpper(), mytext.Substring(1));
                }
            }
            else
            {
                if (mytext.Length == 1)
                {
                    mytext = String.Join(mytext.ToUpper, ".");
                }
                else
                {
                    string first = mytext.First();
                    mytext = String.Join(first.ToUpper(), mytext.Substring(1));
                }

            }
            return mytext;
        }

```