I've always loved VB for its simplicity. When a VB programmer moves to C#/.NET he misses those VB functions that helped him a lot. I wrote few functions to mimic those good old VB functions in C#.
1. Porting Common VB functions to C#: isNumeric()
bool isNumeric(char ch)
{
//If the given character is in between 0 and 9 then
//return true, otherwise false
if (ch >= '0' && ch <= '9')
return true;
else
return false;
}
2. Porting Common VB functions to C#: Asc()
int Asc(char ch)
{
//Return the character value of the given character
return (int)Encoding.ASCII.GetBytes(S)[0];
}
3. Porting Common VB functions to C#: Chr()
Char Chr(int i)
{
//Return the character of the given character value
return Convert.ToChar(i);
}
4. Porting Common functions to C#: isLower()
bool isLower(char ch)
{
//If the given character is in between a and z then
//return true, otherwise false
if (ch >= 'a' && ch <= 'z')
return true;
else
return false;
}
The same function can also be written as more .NET frieldly:
bool isLower(char ch)
{
return Char.IsLower(ch));
}
5. Porting Common functions to C#: isUpper()
bool isUpper(char ch)
{
//If the given character is in between A and Z then
//return true, otherwise false
if (ch >= 'A' && ch <= 'Z')
return true;
else
return false;
}
The same function can also be written as:
bool isUpper(char ch)
{
return Char.IsUpper(ch));
}