| | |
Array in struct
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
I have this C++ code : I want to convert this code into C# syntax.
I tried this one, but don't know how to place array in a struct. Help me please.
C# Syntax (Toggle Plain Text)
const int ANYSIZE_ARRAY = 1; struct LUID {DWORD LowPart; WORD HighPart;}; struct LUID_AND_ATTRIBUTES {LUID Luid; DWORD Attributes;}; struct TOKEN_PRIVILEGES {DWORD PrivilegeCount; LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];};
I tried this one, but don't know how to place array in a struct.
C# Syntax (Toggle Plain Text)
const int ANYSIZE_ARRAY = 1; struct LUID {Int32 LowPart; Int16 HighPart;}; struct LUID_AND_ATTRIBUTES {LUID Luid; Int32 Attributes;}; struct TOKEN_PRIVILEGES {Int32 PriviligeCount; /*WHAT TO WRITE HERE??*/};
Hi
Would it not be something like;
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
for the above i have assumed that, you want an array of LUID_AND_ATTRIBUTES type struct , which you have defined before, as comprising of LUID Luid; int32 Attributes.
If my assunption is wrong, then please accept my apologies.
HTH
Thanks
Would it not be something like;
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
for the above i have assumed that, you want an array of LUID_AND_ATTRIBUTES type struct , which you have defined before, as comprising of LUID Luid; int32 Attributes.
If my assunption is wrong, then please accept my apologies.
HTH
Thanks
•
•
•
•
I have this C++ code :I want to convert this code into C# syntax.C# Syntax (Toggle Plain Text)
const int ANYSIZE_ARRAY = 1; struct LUID {DWORD LowPart; WORD HighPart;}; struct LUID_AND_ATTRIBUTES {LUID Luid; DWORD Attributes;}; struct TOKEN_PRIVILEGES {DWORD PrivilegeCount; LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];};
I tried this one, but don't know how to place array in a struct.Help me please.C# Syntax (Toggle Plain Text)
const int ANYSIZE_ARRAY = 1; struct LUID {Int32 LowPart; Int16 HighPart;}; struct LUID_AND_ATTRIBUTES {LUID Luid; Int32 Attributes;}; struct TOKEN_PRIVILEGES {Int32 PriviligeCount; /*WHAT TO WRITE HERE??*/};
•
•
•
•
Would it not be something like;
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
C# Syntax (Toggle Plain Text)
Error 1 Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type. C:\Prog\SAVE\C#\Shutdown\Main.cs 22 86 Shutdown Error 2 Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) C:\Prog\SAVE\C#\Shutdown\Main.cs 22 87 Shutdown
•
•
•
•
for the above i have assumed that, you want an array of LUID_AND_ATTRIBUTES type struct , which you have defined before, as comprising of LUID Luid; int32 Attributes.
This one doesn't work :
C# Syntax (Toggle Plain Text)
struct Animals { float Bird; int Rabbit[20]; Int64 Elephant; };
Error 2 Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) C:\Prog\SAVE\C#\Shutdown\Main.cs 35 43 Shutdown
This one too :
C# Syntax (Toggle Plain Text)
struct Animals { float Bird; int[20] Rabbit; Int64 Elephant; };
Another one :
C# Syntax (Toggle Plain Text)
struct Animals { float Bird; int Rabbit[]; Int64 Elephant; };
This one works :
C# Syntax (Toggle Plain Text)
struct Animals { float Bird; int[] Rabbit; Int64 Elephant; };

Any suggestions?
![]() |
Similar Threads
- 2D dynamic array within struct (C++)
- Array Struct Sort Help!! Urgent! (C)
- array struct display?? (C)
- Help with copying an array into a struct (C)
Other Threads in the C# Forum
- Previous Thread: Directx or GDI+
- Next Thread: C# .NET Gridview
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





