Removing first or last character of a string with unit-testing
You're checking both the start and end twice and you only modify when both start and end have duplicate letters. Is that intentionally?:


  if (firstName[0] != 'a' &amp;&amp; firstName[firstName.Length - 1] != 'l' &amp;&amp; firstName[firstName.Length - 1] != 'e')
  {
    if (firstName[0] == firstName[1] &amp;&amp; firstName[firstName.Length - 1] == firstName[firstName.Length - 2])
    {
      return firstName.Remove(0, 1).Remove(firstName.Length - 2, 1);
    }
    else if (firstName[0] == firstName[1])
    {
      return firstName.Remove(0, 1);
    }
    else if (firstName[firstName.Length - 1] == firstName[firstName.Length - 2])
    {
      return firstName.Remove(firstName.Length - 1);
    }
  }



It could be simplified to:

  if (string.IsNullOrEmpty(name) || name.Length &lt; 2) return name;

  if (name[0] != 'a' &amp;&amp; name[name.Length - 1] != 'l' &amp;&amp; name[name.Length - 1] != 'e')
  {
    if (name[0] == name[1])
      name = name.Substring(1);
    if (name.Length &gt; 1 &amp;&amp; name[name.Length - 1] == name[name.Length - 2])
      name = name.Substring(0, name.Length - 1);
  }
  return name;




But what about "aaronn" shouldn't the last "nn" be reduced to one 'n' in that?

If so, you'll have to check start and end separately:

string RemoveDuplicatesAtStartAndEnd(string name)
{
  if (string.IsNullOrEmpty(name) || name.Length &lt; 2) return name;

  if (name[0] != 'a' &amp;&amp; name[0] == name[1])
    name = name.Substring(1);
  if (name.Length &gt; 1 &amp;&amp; name[name.Length - 1] != 'l' &amp;&amp; name[name.Length - 1] != 'e' &amp;&amp; name[name.Length - 1] == name[name.Length - 2])
    name = name.Substring(0, name.Length - 1);

  return name;
}


and as shown, you'll also have to validate the input before handling it.



If you want to handle any number of duplicates chars at start and end you can do:

string RemoveDuplicatesAtStartAndEnd(string name)
{
  if (string.IsNullOrEmpty(name) || name.Length &lt; 2) return name;

  while (name.Length &gt; 1 &amp;&amp; name[0] != 'a' &amp;&amp; name[0] == name[1])
    name = name.Substring(1);

  while (name.Length &gt; 1 &amp;&amp; name[name.Length - 1] != 'l' &amp;&amp; name[name.Length - 1] != 'e' &amp;&amp; name[name.Length - 1] == name[name.Length - 2])
    name = name.Substring(0, name.Length - 1);

  return name;
}




Another way could be to use Regex:

string RemoveDuplicatesAtStartAndEnd(string name)
{
  name = Regex.Replace(name, @"^([^a])\1{1,}", m =&gt; m.Value[0].ToString());
  return Regex.Replace(name, @"([^el])\1{1,}$", m =&gt; m.Value[0].ToString());
}


Other regex approaches may be valid, but this is one way to do it.



What about upper-lower case?



Your purpose for this method is not clear, but I wouldn't be confident about it, taken all possible names into account. Manipulate names in this way seems as risky business IMO.