It's always entertaining to see a programmer insist upon implementing his own version of built-in functionality. Especially when the built-in method is literally right infront of you (thanks to Intellisense):
And what makes this reimplementation (found by Stephan Rose) even more fun is that inists upon the caller to convert the string into a character array first and pass in that array's length ...
public bool IsFloat(char[] text, int nLength) { bool UsedDecimal = false; for(int i = 0; i < nLength; i++) { // return TRUE if the character is 0 (the string is over) if(text[i] == 0) return true; // make sure only 1 decimal has been used if(text[i] == '.') if(UsedDecimal == false) UsedDecimal = true; else return false; // return FALSE if the character isn't a digit or there is a minus where there shouldn't be else if( !(text[i] >= '0' && text[i] <= '9') && !(i == 0 && text[i] == '-') ) return false; } return true; }
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!