C
CMoya
Aidy said:What would you rather do? Call "string.Length" or call "len (string)"
that then calls "string.Length" internally? And I don't know how the len
function handles nulls cos I didn't write it and haven't seen the source.
However I know how myString.Length will react if myString is null and I
don't need trial and error or consulting docs to tell me.
I'd rather call Len(str) than do the following in a bunch of places in code:
if (str != null) {
num = str.Length()
}
else {
// do something else. in this case assign: num = 0
}
//(Even worse if I want to duplicate Left/Mid/Right)
What's wrong with calling a reusable Len() "utility" function that does the
same thing as the conditionals above?
Using those functions also makes it harder to understand c# examples. If
you at least use vb.net as intended then reading c# shouldn't be too much
problem, and switching to c# if you want to should be easier.
Is it any different than using utility functions written by other
developers in your team or written by developers employed before you joined
the team... or worse, copy and pasted from the web? Do all C# developers
work alone and bring their redundant encapsulated utility functions to a
project? What a nightmare (that I've personally seen.... at least back in
the day VB coders did this a lot with API vodoo calls-- but C# guys do it
for the most rudimentary things). These built-in utility (standard)
functions are designed to make your life easier and manage projects
easier.... the goal of all high-end computer languages. Except perhaps C#? I
dunno.