sprintf and C#

  • Thread starter Thread starter steve
  • Start date Start date
steve said:
hey i wrote a progam a wihle back in c++ and i used the sprintf
function as follows:

OVERLAPPED osWait = {0};
DWORD dwWritten;

char B[20];

sprintf (B, "\x02" "CB 0 1" "\x0D\x0A\x03");
WriteFile (m_hPort, B, strlen(B), &dwWritten, &osWait);

how do i change this to c#.. just the sprintf part.

From
http://www.developmentnow.com/g/36_0_0_0_0_0/dotnet-languages-csharp.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

With String.Format you can do similar things. The syntax in entirely different though.

Hans Kesting
 
steve said:
hey i wrote a progam a wihle back in c++ and i used the sprintf function
as follows:

OVERLAPPED osWait = {0};
DWORD dwWritten;

char B[20];

sprintf (B, "\x02" "CB 0 1" "\x0D\x0A\x03");
WriteFile (m_hPort, B, strlen(B), &dwWritten, &osWait);

how do i change this to c#.. just the sprintf part.

From
http://www.developmentnow.com/g/36_0_0_0_0_0/dotnet-languages-csharp.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

string s = '\x02' + "CB 0 1\r\n" + '\x03'
or
s = '\x02' + "CB 0 1" + '\x0d' + '\x0a' + '\x03'
or
const char stx = '\x02';
const char etx = '\x03';
s = stx + "CB 0 1\r\n" + etx;
....

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top