Click here to Skip to main content
15,891,423 members
Home / Discussions / C#
   

C#

 
QuestionHiding unwanted properties [modified] Pin
Chris_McGrath12-Apr-07 14:45
Chris_McGrath12-Apr-07 14:45 
AnswerRe: Hiding unwanted properties Pin
AlwiNus14-Apr-07 12:16
AlwiNus14-Apr-07 12:16 
AnswerRe: Hiding unwanted properties Pin
Tristan Rhodes16-Apr-07 3:31
Tristan Rhodes16-Apr-07 3:31 
Questionbarcode scanner Pin
SVb.net12-Apr-07 12:14
SVb.net12-Apr-07 12:14 
AnswerRe: barcode scanner Pin
Christian Graus12-Apr-07 12:21
protectorChristian Graus12-Apr-07 12:21 
AnswerRe: barcode scanner Pin
stancrm12-Apr-07 20:17
stancrm12-Apr-07 20:17 
GeneralRe: barcode scanner Pin
SVb.net15-Apr-07 2:29
SVb.net15-Apr-07 2:29 
QuestionConverting from byte[] to byte* Pin
Kim Ferrari12-Apr-07 10:15
Kim Ferrari12-Apr-07 10:15 
I'm having to write some relatively ugly code when their realy ought to be a better way to do this. I'm sure someone has come across this before.

We are receiving messages from/ sending messages to a legacy host system that MUST be aligned a specific way.

For example I have a structure like:

struct myexample
{
public fixed byte mybytes[15];
public int myint;
public int myint2;
}

I'm not showing it here, but i use the system.runtime.interopServices.FieldOffset to make sure the bytes line up exactly correct.

I go to fill in this structure with some data

public void fillItin(string myString,
int myInt,
int myOtherInt)
{
myexample temp = new myexample();
temp.myint = myInt;
temp.myint2 = myOtherInt;
byte[] myArray = ascii.GetBytes(myString);
// cool I've got it into a byte[] structure, but now I need to convert it to my fixed
//length byte which c# treats as a byte*

// this is what I've been doing, but there MUST be a better way! Confused | :confused:
// Yuck! Way too unelegant of a solution. Help! Roll eyes | :rolleyes:

unsafe
{
for (int i=0;i<myarray.length;i++)
="" {
="" if="" (i="" <="" 15)="" temp.mybytes[i]="myArray[i]
" }
="" }

="" now="" convert="" my="" structure="" to="" a="" byte[]="" array="" (cool="" marshal="" utilities="" work="" well="" here)
="" and="" send="" it="" off="" ...="" some="" code="" here="" the="" message=""
}=""

<div="" class="ForumSig">Kim Ferrari
AnswerRe: Converting from byte[] to byte* Pin
George L. Jackson12-Apr-07 12:08
George L. Jackson12-Apr-07 12:08 
QuestionHow c# app connect to sql server on another pc in local network? Pin
sgeorgije12-Apr-07 9:28
sgeorgije12-Apr-07 9:28 
AnswerRe: How c# app connect to sql server on another pc in local network? Pin
Pete O'Hanlon12-Apr-07 10:10
mvePete O'Hanlon12-Apr-07 10:10 
QuestionRe: How c# app connect to sql server on another pc in local network? Pin
sgeorgije15-Apr-07 1:59
sgeorgije15-Apr-07 1:59 
AnswerRe: How c# app connect to sql server on another pc in local network? Pin
Pete O'Hanlon15-Apr-07 9:24
mvePete O'Hanlon15-Apr-07 9:24 
QuestionMargins on TabControl Tabs Pin
Tojiro12-Apr-07 9:21
Tojiro12-Apr-07 9:21 
Questionsave dialog Box Pin
EEmaan12-Apr-07 9:04
EEmaan12-Apr-07 9:04 
AnswerRe: save dialog Box Pin
Sathesh Sakthivel12-Apr-07 9:15
Sathesh Sakthivel12-Apr-07 9:15 
GeneralRe: save dialog Box Pin
EEmaan12-Apr-07 9:41
EEmaan12-Apr-07 9:41 
AnswerRe: save dialog Box Pin
J$12-Apr-07 10:55
J$12-Apr-07 10:55 
AnswerRe: save dialog Box Pin
Jaiprakash M Bankolli12-Apr-07 19:45
Jaiprakash M Bankolli12-Apr-07 19:45 
QuestionReplacing value in XML Pin
umashankergr812-Apr-07 8:57
umashankergr812-Apr-07 8:57 
AnswerRe: Replacing value in XML Pin
Sathesh Sakthivel12-Apr-07 9:13
Sathesh Sakthivel12-Apr-07 9:13 
GeneralRe: Replacing value in XML Pin
umashankergr812-Apr-07 9:22
umashankergr812-Apr-07 9:22 
AnswerRe: Replacing value in XML Pin
blackjack215012-Apr-07 9:26
blackjack215012-Apr-07 9:26 
GeneralReplacing value in XML Pin
umashankergr812-Apr-07 10:34
umashankergr812-Apr-07 10:34 
GeneralRe: Replacing value in XML Pin
Stefan Troschuetz12-Apr-07 11:23
Stefan Troschuetz12-Apr-07 11:23 

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.