"Rain" <Ra**@discussions.microsoft.comwrote in message
news:A1**********************************@microsof t.com...
1.) i want _msgPro._seqNo + _msgPro._msgLen + Message to be concatenated
and
not plus. I need it to be on the right bytes in sending and in receiving..
any good ideas?
It's not clear from your post what you want to do. The code you posted
seems to be trying to send a string representation of the "MsgProperties"
structure, but if you're going to send the data as a string, there's no
reason to bother with the explicitly layed-out structure you've got.
Regardless of how you want to send the data, you appear to be initializing
your byte array using an uninitialized "MsgProperties" structure.
If you have an *initialized* "MsgProperties" structure called "_msgPro",
*and* you want a string that represents the values in the structure, then
you need to convert each field of the structure to a string, along the lines
of "_msgPro._seqNo.ToString()". Of course, without formatting, the length
of this string will be variable. So you either need to impose some
formatting (using String.Format() instead of the ToString() method of the
fields), or you need to delimit the data with the string somehow (perhaps by
putting spaces between each number).
If you're not actually looking for a string that represents your structure,
then you should forget about using the string stuff altogether. Just send
the structure you've defined.
2.) How can i get for example the 1st 2 bytes or the next 2 bytes of a
string... ?
It's not clear what you are looking for here. The first two bytes of a
String (Unicode) compose the first character of that string. So if you
really want the first two bytes, you just get the first character. Likewise
the next two bytes. If you need to actually convert those to two separate
bytes, the BitConverter class can handle that for you.
3.) Can i place _msgPro._seqNo, _msgPro._msgLen & _msgPro._checkSum in one
variable? what type? how?
It's not clear to me, once again, what you're asking. The "MsgProperties"
structure you've defined does exactly that. The "_msgPro" variable you've
declared stores exactly those values. It seems very odd to me for you to
ask for a different variable to store those values in. If you can explain
more specifically what else you are looking for beyond that, it would help
with respect to getting an actual answer that makes sense.
Pete