Just execute this lines of code and see the results. If you build a
string from a char array like this:
{'B','U','G',0,0,0,0}, the resulting string have a length of 8, and if
you build a new string adding some words to the first string and you
write it you�ll see 'blanks' for the '0' char, like this:
"BUG NEW BUG". My expected result is that the length of the first
string to be 3 (no?) and when I add something the result should be
"BUGNEWBUG". Am I wrong?
using System;
using System.IO;
namespace StringBugTest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
byte[] bytes = new byte[8];
bytes.SetValue((byte)66,0);
bytes.SetValue((byte)85,1);
bytes.SetValue((byte)71,2);
bytes.SetValue((byte)0,3);
bytes.SetValue((byte)0,4);
bytes.SetValue((byte)0,5);
bytes.SetValue((byte)0,6);
bytes.SetValue((byte)0,7);
MemoryStream ms=new MemoryStream(bytes);
BinaryReader bReader=new BinaryReader(ms);
char[] cadena=bReader.ReadChars(8);
string bug=new string(cadena);
Console.WriteLine(bug);
int a=bug.Length;
Console.WriteLine(a);
bug+="NEW BUG";
Console.WriteLine(bug);
}
}
}
Thanks for your attention.
Miguel �ngel Chac�n Esp�n.
Telecinco. Spain.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.