Nathan Alden was tasked with trying to figure out why a customer's system was reporting that a large percentage of inquiries were coming from Nebraska, a state whose total population barely surpasses Manhattan's. Once digging in the code, it was pretty easy to find out why. Apparently, the original programmer didn't quite think to look past the first state on the State Abbreviation List to come up with the formula for calculating them ...

public string GetStateAbbreviation(String stateName)
{
  String stateAbbrev = stateName.ToUpper();

  if (stateName.Length > 2)
  {
    stateAbbrev = stateName.SubString(0, 2);
  }

  return stateAbbrev;
}

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!