Click here to Skip to main content
15,912,897 members
Home / Discussions / C#
   

C#

 
QuestionBlackhole string! Pin
Member 349379912-Mar-09 2:37
Member 349379912-Mar-09 2:37 
AnswerRe: Blackhole string! Pin
musefan12-Mar-09 2:54
musefan12-Mar-09 2:54 
GeneralRe: Blackhole string! Pin
musefan12-Mar-09 3:09
musefan12-Mar-09 3:09 
GeneralRe: Blackhole string! Pin
Member 349379912-Mar-09 3:11
Member 349379912-Mar-09 3:11 
GeneralRe: Blackhole string! Pin
musefan12-Mar-09 3:13
musefan12-Mar-09 3:13 
AnswerRe: Blackhole string! Pin
Luc Pattyn12-Mar-09 3:12
sitebuilderLuc Pattyn12-Mar-09 3:12 
GeneralRe: Blackhole string! Pin
Member 349379912-Mar-09 3:20
Member 349379912-Mar-09 3:20 
GeneralRe: Blackhole string! Pin
Luc Pattyn12-Mar-09 4:26
sitebuilderLuc Pattyn12-Mar-09 4:26 
Hi,

not sure why I am getting all this, thanks anyway.

some remarks:

1.
either this struct has strict requirements or it has not.
if it has, I doubt it should hold both public byte[] dataSenderBytes; and public string dataSender; // 12
same for public byte[] dataMessageBytes; and public string dataMessage; // 24
if it has not, don't see why it should need a Pack=1 attribute

2.
your problem is with string handling.
in the native world (C, C++) strings consist of 8-bit characters (or 16-bit wide characters) and they end on the first ASCII NULL character (byte value zero), which means the NULL character itself cannot be embedded in a string.
in the managed world strings can contain any character you choose; if you give 12 bytes (dataSenderBytes) to ASCII.GetString() it probably returns a 12-character string of which several could be NULL (or \0).

So I suggest you get the meaningful length of those strings somehow from the byte[] or from the native world, then use ASCIIEncoding.GetString(Byte[], 0, length)

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


AnswerRe: Blackhole string! Pin
Nagy Vilmos12-Mar-09 3:19
professionalNagy Vilmos12-Mar-09 3:19 
GeneralRe: Blackhole string! Pin
Member 349379912-Mar-09 3:30
Member 349379912-Mar-09 3:30 
GeneralRe: Blackhole string! Pin
Nagy Vilmos12-Mar-09 3:35
professionalNagy Vilmos12-Mar-09 3:35 
GeneralRe: Blackhole string! Pin
Member 349379912-Mar-09 3:36
Member 349379912-Mar-09 3:36 
GeneralRe: Blackhole string! Pin
Nagy Vilmos12-Mar-09 3:42
professionalNagy Vilmos12-Mar-09 3:42 
GeneralRe: Blackhole string! Pin
Member 349379912-Mar-09 3:45
Member 349379912-Mar-09 3:45 
QuestionMulti-Threading Question Pin
Programm3r12-Mar-09 2:01
Programm3r12-Mar-09 2:01 
AnswerRe: Multi-Threading Question Pin
musefan12-Mar-09 2:11
musefan12-Mar-09 2:11 
GeneralRe: Multi-Threading Question Pin
Programm3r12-Mar-09 2:42
Programm3r12-Mar-09 2:42 
GeneralRe: Multi-Threading Question Pin
Member 349379912-Mar-09 2:44
Member 349379912-Mar-09 2:44 
GeneralRe: Multi-Threading Question Pin
musefan12-Mar-09 2:47
musefan12-Mar-09 2:47 
QuestionRe: Multi-Threading Question Pin
Programm3r12-Mar-09 2:59
Programm3r12-Mar-09 2:59 
AnswerRe: Multi-Threading Question Pin
musefan12-Mar-09 3:08
musefan12-Mar-09 3:08 
GeneralRe: Multi-Threading Question Pin
Programm3r12-Mar-09 3:28
Programm3r12-Mar-09 3:28 
AnswerRe: Multi-Threading Question Pin
Luc Pattyn12-Mar-09 3:19
sitebuilderLuc Pattyn12-Mar-09 3:19 
GeneralRe: Multi-Threading Question Pin
Programm3r12-Mar-09 4:16
Programm3r12-Mar-09 4:16 
GeneralRe: Multi-Threading Question Pin
Luc Pattyn12-Mar-09 4:28
sitebuilderLuc Pattyn12-Mar-09 4:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.