Dennis,
| Jay, this has no relevance to this thread
I take it you mean your comments has no relevance to which exception. ;-)
| but I noted that sr was returned by
| VB.Net as nothing
What is "sr returned by VB.NET"?
| as are other VB.Net varibles that can't be initialized.
All VB.NET variables can be initialized! can you give me an example of one
that cannot?
| This got me into the habit of returning nothing for reference type
variables
| from some of my routines when something couldn't be found.
Yes returning Nothing is handy sometimes, returning a "NullObject" is
usually handier, aka Special Case pattern.
http://www.martinfowler.com/eaaCatalog/specialCase.html
| For example, I do
| some work with reading and manipulating ID3 tags from mp3 files and when
my
| routines can't find a tag item, the string is returned as nothing.
Do you need to know specifically if its not found? If I don't specifically
need to know I will return String.Empty rather then Nothing, allowing me to
use instance methods on the string as normal. I would consider throwing an
exception for not found, especially if not found does not allow me to
continue. I would consider returning Nothing if I needed to know
specifically, but would then rather quickly change it to String.Empty to
continue processing... I would consider using ByRef parameters to return a
non-Nothing string & an boolean indicator if its found or not, however this
feels like returning an object other then string (such as a ID3Tag class
that I defined) that encapsulated the found string or String.Empty the fact
none was found.
Hope this helps
Jay
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
| Jay, this has no relevance to this thread but I noted that sr was returned
by
| VB.Net as nothing as are other VB.Net varibles that can't be initialized.
| This got me into the habit of returning nothing for reference type
variables
| from some of my routines when something couldn't be found. For example, I
do
| some work with reading and manipulating ID3 tags from mp3 files and when
my
| routines can't find a tag item, the string is returned as nothing.
However,
| in every tag, I must check for either the tag isn't there or the text
| associated with the tag is "". This is what made me wish that things like
| String.trim(x) would just return nothing when x is nothing!
|
<<xnip>>