In connection with this question: How to convert UPC-E to UPC-A?, I found and adapted a method to convert UPC-E barcodes to UPC-A:
public static string ConvertUPCEToUPCA(string UPCE)
{
try
{
int UPCLen;
string UPCA = "";
int chkInt;
UPCLen = UPCE.Length;
FormatString formatString = new FormatString();
if (formatString.containsAlpha(UPCE) != -1)
{
UPCLen = 11;
}
if (UPCLen == 7) // Didn't enter a check digit
{
UPCE = UPCE.Substring(1,6);
}
else if (UPCLen == 8) // Entered both check digit and leading 0 digit
{
UPCE = UPCE.Substring(2,6);
}
if (UPCLen < 9)
{
chkInt = Convert.ToInt32(UPCE.Substring(5,1));
switch (chkInt)
{
case 0:
case 1:
case 2:
UPCA = UPCE.Substring(0,2) + UPCE.Substring(5,1) + "0000" + UPCE.Substring(2,3);
break;
case 3:
UPCA = UPCE.Substring(0,3) + "00000" + UPCE.Substring(3,2);
break;
case 4:
UPCA = UPCE.Substring(0,4) + "00000" + UPCE.Substring(4,1);
break;
case 5:
case 6:
case 7:
case 8:
case 9:
UPCA = UPCE.Substring(0,5) + "0000" + UPCE.Substring(5,1);
break;
default:
break;
}
UPCA = "0" + UPCA;
}
return UPCA;
}
catch(Exception ex)
{
Duckbill.ExceptionHandler(ex, "PlatypusUtils.ConvertUPCEToUPCA(UPCE)");
}
}
...but I'm getting, "Not all code paths return a value." Why? Isn't the "return UPCA;" line reached no matter what?