Click here to Skip to main content
15,886,788 members
Home / Discussions / C#
   

C#

 
GeneralRe: help needed for voip Pin
aamirzada30-Sep-09 0:44
aamirzada30-Sep-09 0:44 
AnswerRe: help needed for voip Pin
Christian Graus29-Sep-09 22:10
protectorChristian Graus29-Sep-09 22:10 
Questiondetect javascript code for google ad sense Pin
Anil Veeraghattapu 429-Sep-09 21:29
Anil Veeraghattapu 429-Sep-09 21:29 
AnswerRe: detect javascript code for google ad sense Pin
benjymous29-Sep-09 21:50
benjymous29-Sep-09 21:50 
GeneralRe: detect javascript code for google ad sense Pin
Anil Veeraghattapu 429-Sep-09 22:55
Anil Veeraghattapu 429-Sep-09 22:55 
GeneralRe: detect javascript code for google ad sense Pin
benjymous30-Sep-09 1:04
benjymous30-Sep-09 1:04 
QuestionHow to define an inline array of a contstant size in a C# structure Pin
maheesh29-Sep-09 21:13
maheesh29-Sep-09 21:13 
AnswerRe: How to define an inline array of a contstant size in a C# structure Pin
Luc Pattyn30-Sep-09 0:45
sitebuilderLuc Pattyn30-Sep-09 0:45 
Hi,

some comments/questions:

1.
if you get an exception, you should provide all the information about it.

2.
with a using System.Runtime.InteropServices; statement at the top, you don't need to fully qualify all the Marshal attributes.

3.
why do you define your struct twice? and differently?

4.
most often a struct gets a constructor, taking some parameters, and initializing all members. So you don't really need a Create() method.

5.
your code, and several variations on it, work for me. as in:
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct tPacket {    
	/// WORD->unsigned short    
	public ushort word1;    
	/// WORD->unsigned short    
	public ushort word2;    
	/// BYTE->unsigned char    
	public byte byte1;   
	 /// BYTE->unsigned char   
	 public byte byte2;    
	/// BYTE[8]
	[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst=8, ArraySubType=UnmanagedType.I1)]   
	public byte[] array123;

	public static tPacket Create() {       
		return new tPacket() { array123 = new byte[8] };
	}
}
...
	tPacket p=tPacket.Create();
	for (byte i=0; i<8; i++) p.array123[i]=i;


6.
For readability code needs indentation. And PRE tags tend to preserve such formatting.

Smile | :)

Luc Pattyn

Local announcement (Antwerp region): Lange Wapper? Neen!


GeneralRe: How to define an inline array of a contstant size in a C# structure Pin
maheesh30-Sep-09 2:42
maheesh30-Sep-09 2:42 
GeneralRe: How to define an inline array of a contstant size in a C# structure Pin
Luc Pattyn30-Sep-09 2:56
sitebuilderLuc Pattyn30-Sep-09 2:56 
GeneralRe: How to define an inline array of a contstant size in a C# structure Pin
maheesh30-Sep-09 3:35
maheesh30-Sep-09 3:35 
GeneralRe: How to define an inline array of a contstant size in a C# structure Pin
Luc Pattyn30-Sep-09 3:49
sitebuilderLuc Pattyn30-Sep-09 3:49 
Questionhow to convert bmp image to hexa conversion ??? Pin
JC.KaNNaN29-Sep-09 21:02
JC.KaNNaN29-Sep-09 21:02 
AnswerRe: how to convert bmp image to hexa conversion ??? Pin
0x3c029-Sep-09 21:15
0x3c029-Sep-09 21:15 
GeneralRe: how to convert bmp image to hexa conversion ??? Pin
JC.KaNNaN29-Sep-09 23:00
JC.KaNNaN29-Sep-09 23:00 
GeneralRe: how to convert bmp image to hexa conversion ??? Pin
0x3c030-Sep-09 5:26
0x3c030-Sep-09 5:26 
QuestionAlter A query In Access using c# Pin
Abdul Rahman Hamidy29-Sep-09 20:43
Abdul Rahman Hamidy29-Sep-09 20:43 
AnswerRe: Alter A query In Access using c# Pin
Abdul Rahman Hamidy30-Sep-09 3:06
Abdul Rahman Hamidy30-Sep-09 3:06 
Questionchange property return type dynamically Pin
$unil Dhiman29-Sep-09 20:12
$unil Dhiman29-Sep-09 20:12 
AnswerRe: change property return type dynamically Pin
Christian Graus29-Sep-09 20:20
protectorChristian Graus29-Sep-09 20:20 
GeneralRe: change property return type dynamically Pin
$unil Dhiman29-Sep-09 20:33
$unil Dhiman29-Sep-09 20:33 
GeneralRe: change property return type dynamically Pin
Christian Graus29-Sep-09 22:12
protectorChristian Graus29-Sep-09 22:12 
Questiondatagrid combobox column Pin
Member 59031029-Sep-09 19:47
Member 59031029-Sep-09 19:47 
AnswerRe: datagrid combobox column Pin
Greg Chelstowski29-Sep-09 21:28
Greg Chelstowski29-Sep-09 21:28 
Questiondatetime picker in datagridview c# 2008 Pin
abcurl29-Sep-09 18:04
abcurl29-Sep-09 18:04 

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.