Tina wrote:
Not to drag on this point but....
What are the "Classic VB Crutch Methods" that you refer to?
He's referring to the Microsoft.VisualBasic namespace, and the stuff
therein. However, I would disagree with the 'crutch' characterization -
the VB namespace functions generally do things in a more 'Basic-like'
way.
For example, this namespace contains a Left function, for taking the
left n characters of a string - C#ers would do this with
String.Substring. However, Left includes additional sanity checks, as
shown by this Reflector output:
public static string Left(string str, int Length)
{
if (Length < 0)
{
throw new
ArgumentException(Utils.GetResourceString("Argumen t_GEZero1",
"Length"));
}
if ((Length == 0) || (str == null))
{
return "";
}
if (Length >= str.Length)
{
return str;
}
return str.Substring(0, Length);
}
Now, the C# 'attitude' would be to say that, for example, anyone who
asks for the left 6 characters of a 3 character string, or the left 4
characters of a null string variable, deserves everything they get. The
VB 'attitude' is that the former should get the string itself, and the
latter should get an empty string
Anycode using the Microsoft.VisiualBasic.Compatibility namespace, on
the other hand, should be rewritten asap.
--
Larry Lard
Replies to group please