C
Clinton Pierce
I'm calling a method in another assembly that's supposed to return a
string, and possibly that string might be empty. The code looks
something like this:
string d = r.Field("date").ToString();
Console.WriteLine(count++ + " '" + d + "' --> " + d.Length);
Sometimes "d" should be empty, and sometimes it's a date string. And
in the VS.NET watch window, it's indeed empty. Except that my
diagnostic line sometimes prints just the number and the opening quote
mark. So the output looks like this:
23 '20020718' --> 8
24 '20020602' --> 8
25 '20010616' --> 8
26 '20010613' --> 8
27 '20010204' --> 8
28 '29 '30 '20020731' --> 8
31 '20010814' --> 8
The line that begins with "28" printed only the sequence number and
the opening quote. Where's the rest of it? In fact, the
Console.Writeline didn't print the newline character.
If I build a condition like this:
if (d.Length == 0)
runThisCode();
The condition is never met, although the debugger is showing that the
string has a 0 length (by putting d.Length in a watch window).
This string has no nulls and no unicode characters. Wrapping the
Console.Writeline in a try/catch block doesn't seem to indicate any
exceptions are being thrown (normally they'd be caught higher up in
this particular program).
I'm completely at a loss. Help!
string, and possibly that string might be empty. The code looks
something like this:
string d = r.Field("date").ToString();
Console.WriteLine(count++ + " '" + d + "' --> " + d.Length);
Sometimes "d" should be empty, and sometimes it's a date string. And
in the VS.NET watch window, it's indeed empty. Except that my
diagnostic line sometimes prints just the number and the opening quote
mark. So the output looks like this:
23 '20020718' --> 8
24 '20020602' --> 8
25 '20010616' --> 8
26 '20010613' --> 8
27 '20010204' --> 8
28 '29 '30 '20020731' --> 8
31 '20010814' --> 8
The line that begins with "28" printed only the sequence number and
the opening quote. Where's the rest of it? In fact, the
Console.Writeline didn't print the newline character.
If I build a condition like this:
if (d.Length == 0)
runThisCode();
The condition is never met, although the debugger is showing that the
string has a 0 length (by putting d.Length in a watch window).
This string has no nulls and no unicode characters. Wrapping the
Console.Writeline in a try/catch block doesn't seem to indicate any
exceptions are being thrown (normally they'd be caught higher up in
this particular program).
I'm completely at a loss. Help!