1
Reply

C to C#

john ranella

john ranella

Jun 24 2015 5:36 AM
382
Hi,
I have a lot of code written in C to convert to C#.
Now the scenario is:

- some modules written in C with public/private variables and public/private void or functions
- each module interacts with another module for example
module a get/set public variable of module b
module b call function of module a and module c

which is the best way to convert all code?

my first thought is to use static for reproduce c modules, but i need to instantiate and inherit the classes

my second thought is to create a new class with the variables and then pass the class to other class: for example

[CODE]

v v1 = new v();
a a1 = new a(ref v1);
b b1 = new b(ref v1);

// class with global variables
public class v
{
public string test = "fsfdsfds";
}

public class a
{

v var;

public a (ref v v1)
{
var = v1;

}

public void test(string s)
{
var.test = s;

}

}

{
public class b
{
v var;

public b (ref v v1)
{
var = v1;
}

}

[/CODE]

but i'm not shure if is correct.

I do not have enough experience in C #, you can give me some advice/example?

Answers (1)