Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
C#
using System;

class Ad
{
    public static void Main()
    {
        Console.WriteLine("sadjfas      A");
    }
}

class Abc
{
    public static void Main()
    {

        Console.WriteLine("another class");
    }
}




i have tried this

To Compile -> csc filename.cs/main:Abc

But doesn`t work.
Posted
Updated 17-Feb-12 3:14am
v4
Comments
Ed Nutting 17-Feb-12 7:14am    
Programs can only have one Main method. You would either have to have two programs or have the main method call to other methods to start different new windows.
dsomay 17-Feb-12 7:30am    
i was reading a book of c#, there is an example of this kind.
But as i tried it doesn`t work.
Ed Nutting 17-Feb-12 7:33am    
Have you posted the exact code from the book? Are you sure your compiler worked? What error did you get?
dsomay 17-Feb-12 7:42am    
Error message:

Source file `a.cs/main:Abc` could not be found
fatal error CS2000: No Input specified
Ed Nutting 17-Feb-12 7:46am    
This isn't a problem with your program - your compiler can't find the file to compile - check your file is in the same directory as the console's current directory. Use the cd command to change the current directory of the console.

 
Share this answer
 
v2
Comments
dsomay 17-Feb-12 7:45am    
example in the link explains about class and its object having one Main method
Varun Sareen 18-Feb-12 2:03am    
Dear Friend, I have modified my solution.
Follow this:

Multiple Main Method in C#[^]


hope it helps :)
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900