?
Solved

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

Posted on 2006-03-24
5
Medium Priority
?
887 Views
Last Modified: 2008-03-06
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;
0
Comment
Question by:Mokwaja
  • 3
5 Comments
 
LVL 10

Expert Comment

by:dkloeck
ID: 16278810
what does the #0 mean in delphi,
you are at the c# programming forum you know ;)
0
 
LVL 10

Accepted Solution

by:
dkloeck earned 600 total points
ID: 16279619
as the #0 you can just use a byte and convert it to the right char if needed
0
 
LVL 10

Expert Comment

by:dkloeck
ID: 16279641
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
0
 
LVL 12

Expert Comment

by:sumix
ID: 16280143
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});
0
 

Author Comment

by:Mokwaja
ID: 16280221
Cool thanks dkloeck and sumix!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question