Click here to Skip to main content
15,919,434 members
Home / Discussions / C#
   

C#

 
GeneralMicrosoft Exchange programming Pin
Ola Carlsson2-Oct-02 3:43
Ola Carlsson2-Oct-02 3:43 
GeneralRe: Microsoft Exchange programming Pin
Michael P Butler2-Oct-02 4:00
Michael P Butler2-Oct-02 4:00 
GeneralRe: Microsoft Exchange programming Pin
Stephane Rodriguez.2-Oct-02 4:18
Stephane Rodriguez.2-Oct-02 4:18 
GeneralCalling COM Object in C# Pin
RAVI H R1-Oct-02 20:06
RAVI H R1-Oct-02 20:06 
GeneralRe: Calling COM Object in C# Pin
Stephane Rodriguez.1-Oct-02 20:44
Stephane Rodriguez.1-Oct-02 20:44 
GeneralRe: Calling COM Object in C# Pin
RAVI H R1-Oct-02 23:05
RAVI H R1-Oct-02 23:05 
GeneralRe: Calling COM Object in C# Pin
Stephane Rodriguez.1-Oct-02 23:41
Stephane Rodriguez.1-Oct-02 23:41 
GeneralRe: Calling COM Object in C# Pin
RAVI H R2-Oct-02 0:29
RAVI H R2-Oct-02 0:29 
GeneralHelp reading a binary file Pin
David Williams1-Oct-02 13:36
David Williams1-Oct-02 13:36 
GeneralRe: Help reading a binary file Pin
leppie1-Oct-02 14:35
leppie1-Oct-02 14:35 
GeneralRe: Help reading a binary file Pin
David Williams2-Oct-02 7:06
David Williams2-Oct-02 7:06 
GeneralRe: Help reading a binary file Pin
leppie2-Oct-02 9:30
leppie2-Oct-02 9:30 
David Williams wrote:
Yep. This works, and you do have the bit ops correct. Thanks

Cool Smile | :)

I remembered I saw something like << 16 for Int32 , so the guess was made accordingly WTF | :WTF: hehe.

However, the way I did it may not be (and probably is not) efficient.

You maybe use the Encoding class (UTF8 and Unicode (BigEndian) ) in a reverse fashion, it sounds a lot like you are dealing with a UTF8 to Unicode(BigEndian) conversion.

Alternatively, the more "dangerous" way is to use a bit of marshalling, remember what I said about the way the data is laid out in memory. So make a small converter.

ushort[] ConvertToUShortArray( byte[] array)
{
	int size = Marshal.SizeOf(typeof(byte)) * array.Length;
	ushort[] output = new ushort[array.Length/2];
	IntPtr ptr = Marshal.AllocHGlobal(size);
	Marshal.Copy(array, 0, ptr, array.Length);
	Marshal.PtrToStructure(ptr, output); //hope this works ??
	Marshal.FreeHGlobal(ptr);
	return (ushort[])output;
}

Ugly!! but efficient Smile | :)

Hope this helps Smile | :)

Give them a chance! Do it for the kittens, dear God, the kittens!
As seen on MS File Transfer: Please enter an integer between 1 and 2.
GeneralRe: Help reading a binary file Pin
30-Oct-02 8:45
suss30-Oct-02 8:45 
GeneralRe: Help reading a binary file Pin
Paul Riley2-Oct-02 4:50
Paul Riley2-Oct-02 4:50 
GeneralRe: Help reading a binary file Pin
James T. Johnson2-Oct-02 5:38
James T. Johnson2-Oct-02 5:38 
GeneralRe: Help reading a binary file Pin
Paul Riley2-Oct-02 5:44
Paul Riley2-Oct-02 5:44 
GeneralRe: Help reading a binary file Pin
David Williams2-Oct-02 7:10
David Williams2-Oct-02 7:10 
GeneralRe: Help reading a binary file Pin
Eric Gunnerson (msft)2-Oct-02 11:30
Eric Gunnerson (msft)2-Oct-02 11:30 
GeneralRe: Help reading a binary file Pin
leppie2-Oct-02 11:39
leppie2-Oct-02 11:39 
GeneralRe: Help reading a binary file Pin
David Williams3-Oct-02 7:00
David Williams3-Oct-02 7:00 
GeneralRe: Help reading a binary file Pin
David Williams3-Oct-02 7:38
David Williams3-Oct-02 7:38 
GeneralRe: Help reading a binary file Pin
Eric Gunnerson (msft)3-Oct-02 8:17
Eric Gunnerson (msft)3-Oct-02 8:17 
GeneralPopUp A form in Multi-window environment Pin
Chris#1-Oct-02 5:43
Chris#1-Oct-02 5:43 
GeneralRe: PopUp A form in Multi-window environment Pin
Stephane Rodriguez.1-Oct-02 7:13
Stephane Rodriguez.1-Oct-02 7:13 
GeneralRe: PopUp A form in Multi-window environment Pin
leppie1-Oct-02 7:15
leppie1-Oct-02 7:15 

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.