Click here to Skip to main content
11,485,564 members (77,673 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ C C# VC++
how to use this in C#

i have a structure in C++,
i creates a typedef of array of this structure
now i want to use this typedef as argument in a C# function as input.
struct node
int x;
string y;
typedef node pyu=new node[65];

void func(pyu a,char c)

now i want this functionality to be done C#.
if anyone has any idea then please guide me .
Posted 5-Dec-12 19:56pm
Edited 5-Dec-12 20:00pm
Sergey Alexandrovich Kryukov at 6-Dec-12 1:04am
You you familiar with P/Invoke in general? Is this C++ or C++/CLI?
vaibhavbvp at 6-Dec-12 1:16am
this is C++
want to write a same version in C#,without using P/invoke
Argonia at 6-Dec-12 4:44am
why just don't you make a class instead of this struct in c#?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You should use native string type instead of stl string:
In C++ it will be looks:
struct node
    int x;
    char y[256];
And in C# it will be wrapped
public struct node
    public int x;
    public string y;
For Unicode you should change type char to wchar_t in C++ structure and CharSet attribute value in C# structure.
More info:[^]

vaibhavbvp at 6-Dec-12 1:22am
hi Maxim
i dont want to use C++ structure
i want to create the separate structure in c# then used that structure as separate datatype(typdef in c++),then using this in the datatype of C# arguments
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

are you talking about

using IntList = List<int>;</int>
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

It's more or less the same in C#, see the documentation[^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 380
1 Maciej Los 365
2 Mehdi Gholam 210
3 Frankie-C 134
4 OriginalGriff 134
0 Sergey Alexandrovich Kryukov 8,819
1 OriginalGriff 7,982
2 Sascha Lefèvre 3,199
3 Maciej Los 2,841
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 6 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100