Skip to content

ASCII character 1 in C#

Mark

Asked Dec 8, 2005, 7:34 AM EST1 answer
Share
LinkedInX
Hello,

I need to communicate a delimiter to a customer, so that they know in a sentence : "Hey, here starts a new line"
We want to use a character which cannot be used by the users of the application.

I want to use the first ASCII character. How do I split up my large string with ascii character 1 in C#?

I think not char(1)  because char is unicode.

Thans in advance

Mark.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Just put char '\x0000' inside the string where you like and split with it.

    string hello = "Hello0\x0000Hello1\x0000Hello2\x0000Hello3\x0000Hello4";
    Console.WriteLine(hello);

    string[] splits = hello.Split(new char[] {'\x0000'});
    foreach (string str in splits)
    {
    &nbsp&nbsp&nbsp Console.WriteLine(str);
    }


    Isn't ASCII 0x00 and Unicode 0x0000 exactly the same character...?
    0