Two Entrey Points (Main() methods in single file)

hey Guys !
                     Today we will discuss name of the topic of "Two entry point in a single file of c#".
first of all you have to make a file in your console application. Then just made Two class along with his own Main() method.

so here we go........
your file name is krishan.cs..
suppose you have a student class
class student
{
            Public  static void Main()
{
              Console.WriteLine("This is first method");
}
}
and now we are making a another class name is Teacher


class Teacher
{
// In this Teacher class we are making a another Main() method...
// c# concept don't take a permission of this doing like ....Two entry point
   Public static void Main()
{
        Console.WriteLine("This is Second Method");

}
}
Now if your compile this code then you got the error message that you have a Two entry point in your class.

Now for solve this problem...go to command prompt of your Visual Studio.

now goto c:/ drive..and for compiling for your code...you have to write this line
c:/>csc krishan.cs /main:student

explain the above line:this line is compiling your code..
(csc) is a keyword
(krishan.cs) is file name of your console application.
(/main:student) which one Main() method will be compile of your application.

With the above line we have created a .exe file of our student.cs class.

(krishan.exe) execute this line in your command prompt.
and you get the result according to your appication..
i hope you will enjoy with this suggestion.......

Comments

Popular posts from this blog

Understanding ASP.NET MVC using real world example, for beginners and intermediate

iphone review

Unable to add google gmail in iphone