Monday, July 18, 2011

How to use multiple main in csharp

using System;

class ClassA
{
public static void Main()
{
Console.WriteLine("Class A");
}
}
class ClassB
{
public static void Main()
{
Console.WriteLine("Class B");
}
}



save this file as abc.cs
and compile with csc abc.cs/main:classA if you choose classA as entry point
and compile with csc abc.cs/main:classB if you choose classB as entry point

1 comment:

  1. just add a keyword 'public' to one of your classes and then check the result for yourself.
    Example: public class ClassA{//rest all code same.

    Please also check to see if you place the 'public' in front of both the class declarations you will get a compile time error. I hope it will help you.

    ReplyDelete

Your comment is pending for approval

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...