How do you choose 1 entry point when C# project has more Main( ) method?

A) Not Possible
B) Using /Main along with class name in csc.exe
C) By just providing the class name to csc.exe

Showing Answers 1 - 5 of 5 Answers

Bhuvneshwar P Sharma

  • Jan 2nd, 2006
 

Answer is B

In one .cs file there may be many classes having Main() method. While making the .exe you can define the class name as an entry point

CSC /main:classname filename.cs

  Was this answer useful?  Yes

Shree

  • Jan 25th, 2006
 

Could you please state an example .Thank You

  Was this answer useful?  Yes

Nanda

  • Feb 25th, 2006
 

Hi

Assume that u have a c# file called all.cs, which as the below three classes..\

using System;

namespace com.all
{
public class Class1
{
public static void Main(String[] args)
{
Class3 c = new Class3();
c.display();

Console.WriteLine("Hello");
}
}


public class Class3
{
public void display()
{
Console.WriteLine("Class3");
}
}

public class Class2
{
public static void Main(String[] args)
{
Console.WriteLine("Class2");
}
}

}

In the above program both class1 & class2 as the entry points. So if you compile the above prog using the normal command say "csc all.cs" it would return error, so to fix or choose the entry point you have to use the /main switch with csc command.

Suppose, say u are interested in class2 for choosing its entry point, then you have to execute the below command

csc /main:com.all.Class2 all.cs

I think the above progrom would sound good for u.

  Was this answer useful?  Yes

gayathri

  • Apr 19th, 2006
 

Insteaad of comment prompt i needto execute in GUI interface in web application itself by giving build that how can i implement when both the class having main

  Was this answer useful?  Yes

Dhandapani

  • Dec 31st, 2006
 

open the project properties, in the common properties/general set the start up object(it will list all the classes having main function).

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions