> I am using reflection to initialize a string to a value.
>
[quoted text clipped - 38 lines]
>
> PRASHANT
Ok, i have found out that the problem is not due to reflection but due to
this-
if i make a char array which is even 1 more than the length of string to be
stored-
char[] a = new char[len+1];
and store chars in it till len and then make a string out of the array-
string s =a.ToString();
the returned string has "\0" in it.
So if the string you copied is "Hello" but if you compare it with "Hello"
it will fail-
if(s=="Hello") //this FAILS!
To make the test pass you have to do include the "\0" in the string, like
this-
if(s=="Hello\0")//this PASSES!
but strangely if you check for length it will return it to you without
considering the null.
int len = s.Length;// len is equal to 5. NOT 6
This seems to be a bug in .NET 1.0.
PRASHANT
> Have you parsed the last character out of the string and then seen what the
> ASC value is?
[quoted text clipped - 52 lines]
> >
> > PRASHANT
Ken Pinard - 05 Jan 2004 02:39 GMT
Actually, this has been a feature of "C" since the beginning. If the length
was greater than 1 more than the length. It would have any previously
assigned character in the last character.
You need to do your own checking.
Ken
> Ok, i have found out that the problem is not due to reflection but due to
> this-
[quoted text clipped - 78 lines]
> > >
> > > PRASHANT