While exploring the dank catacombs and dusty dungeons of our legacy code, I came across this:
FormatString formatString = new FormatString();
if (formatString.containsAlpha(UPCE) != -1)
{
UPCLen = 11;
}
Am I missing something, or is my reaction to this, namely: How can formatString contain anything? Nothing has been assigned to it...It will always be -1, assuming that indicates 'not found'" correct?
UPDATE
In answer to the general confusion evident in the comments, I thought FormatString was some haywire stone ages .NET thing (this project uses .NET 1.1), but you're right - this is a homegrown class. Here is the constructor:
public FormatString()
{
}
...and the containsAlpha() method:
public int containsAlpha(string strToCheck)
{
const string ALPHA_CHARS = "abcdefghijklmnopqrstuvwxyz";
try
{
char[] tmpCharArry = ALPHA_CHARS.ToCharArray();
return strToCheck.ToLower().IndexOfAny(tmpCharArry);
}
catch(Exception ex)
{
Duckbill.ExceptionHandler(ex, "FormatString.containsAlpha");
return 0; // not -1?
}
}
Now I ask you: Is "FormatString" a wrong-headed name for this class, or what? I found it very misleading (obviously).