struct array in C#
-
Hi all, How can I perform the following C++ structure code within C#?
struct EmpStruct { char name[15]; char surname[15]; }EMP[100];
Many thanks in advance Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Hi all, How can I perform the following C++ structure code within C#?
struct EmpStruct { char name[15]; char surname[15]; }EMP[100];
Many thanks in advance Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Is this correct:
public struct EMP { public string name; public string surname; } .... EMP [] employee = new EMP[100]; ....
Many thanks in advance Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Is this correct:
public struct EMP { public string name; public string surname; } .... EMP [] employee = new EMP[100]; ....
Many thanks in advance Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Is this correct:
public struct EMP { public string name; public string surname; } .... EMP [] employee = new EMP[100]; ....
Many thanks in advance Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Hi, there is a difference: in unmanaged C/C++ the struct EmpStruct has a size of 30 (or 32), since it contains 30 characters. your C# struct has a size of 8 (or 16 on Win64) since it contains two references and no characters. So it all depends what you are trying to do: - if you are porting a C/C++ app to C#, it could be good enough; - if you want your C# to cooperate with existing software or hardware that needs the original struct EmpStruct, then it is not OK, and you will need special Marshalling instructions. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - 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 PRE tags to preserve formatting when showing multi-line code snippets.
-
No, not yet ... but according to some code snippets I saw on the web it looks like it will work. Thanks for the response.
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Hi, there is a difference: in unmanaged C/C++ the struct EmpStruct has a size of 30 (or 32), since it contains 30 characters. your C# struct has a size of 8 (or 16 on Win64) since it contains two references and no characters. So it all depends what you are trying to do: - if you are porting a C/C++ app to C#, it could be good enough; - if you want your C# to cooperate with existing software or hardware that needs the original struct EmpStruct, then it is not OK, and you will need special Marshalling instructions. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - 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 PRE tags to preserve formatting when showing multi-line code snippets.
Thanks for the response Luc, well I'm rewriting a application into C# from C++ .... so that is the only reason I was asking. Thanks again Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Thanks for the response Luc, well I'm rewriting a application into C# from C++ .... so that is the only reason I was asking. Thanks again Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
the structs are value types and classes are reference types.
f(yf) = yf
-
Hi all, How can I perform the following C++ structure code within C#?
struct EmpStruct { char name[15]; char surname[15]; }EMP[100];
Many thanks in advance Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
You are looking for
FixedBufferAttribute
[^]xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 3 out now