c# Char, Delphi code translate - Need quick answer, easy points!

Hi,

I need to do the same as below (Delphi code) but in c#, I'm not sure about the #0 Char part:

...SendStr(#0 + Chr(Length(DataRec)) + DataRec);

Just this line above, how do I do this in c#, not the sending just the #0 part in the beginning?

Full code

If TCPClient.Socket.Connected Then
        Begin
          If Length(DataRec) > 256 Then
          Begin
              If Length(DataRec) > 512 Then
              Begin
                  TCPClient.Socket.SendStr(#2 + Chr(Length(DataRec) - 512) + DataRec);
                  Memo2.Lines.Add('DataOut: ' + #2 + Chr(Length(DataRec) - 512) + DataRec);
              End
              Else
              Begin
                  TCPClient.Socket.SendStr(#1 + Chr(Length(DataRec) - 256) + DataRec);
                  Memo2.Lines.Add('DataOut: ' + #1 + Chr(Length(DataRec) - 256) + DataRec);
              End;
          End
          Else
          Begin
              TCPClient.Socket.SendStr(#0 + Chr(Length(DataRec)) + DataRec);
              Memo2.Lines.Add('DataOut: ' + Chr(Length(DataRec)) + DataRec);
          End;
MokwajaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dkloeckCommented:
what does the #0 mean in delphi,
you are at the c# programming forum you know ;)
dkloeckCommented:
as the #0 you can just use a byte and convert it to the right char if needed

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dkloeckCommented:
char is allways a 16 bit in c# but you could check if the char you get is part of the byte uyou want to use and send it as byte
sumixCommented:
For #0 you can do (char)0 (returns a char) or \u0000 (returns a string), but both are Unicode.

Chr(Length(DataRec))
          can be translated in c# like:
System.Text.Encoding.ASCII.GetString(new byte[]{(byte)DataRec.Length});
MokwajaAuthor Commented:
Cool thanks dkloeck and sumix!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.