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.
use firstordefault() instead of first(). first throwing an exception in case there are no elements