exe file written in C#
which i need to return a complex return value to another C# project
Here is my code:
class Program
{
private class MyObject
{
private int num;
public int Num
{
get
{
return (this.num);
}
set
{
this.num = value;
}
}
public MyObject(int num)
{
this.Num = num;
}
}
[STAThread]
public static MyObject Main(string[] args)
{
return new MyObject(5);
}
}
this gives me the following error:
…\ConsoleApplication1.exe’
does not contain a static ‘Main’ method suitable for an entry point.
I’ve tried playing with it but i got no success in making it return a complex value.
You can’t do this from a
Mainmethod which is meant to be the entry point of the process.If you’re writing code to be called directly from other code, you should almost certainly be building a Class Library project instead. You can add a reference from one application to another, but it’s unusual (at least outside unit tests). If you want to do this, you should just call a different method instead of
Main. (You could have aMainmethod declared that way in one class, and use a different class as the “normal” entry point, but that seems pointlessly complicated.)