Multiple Classes In Multiple Files

With the help of this program i want to describe that hows we can create different class in different file and at last we can compile all the file to make one exe file.

-------------------------------------------------------------------------------
Create a file and save the file named :- ClassATest.cs

using System;

class ClassATest
{
public void Display()
{
Console.WriteLine("Hi ! I am in ClassATest");
}
}

Notice i did not define the Main method in this class file.
-----------------------------------------------------------------------------

Create a second file and save the file named :- ClassBTest.cs

using System;

class ClassBTest
{
public static void Main()
{
ClassATest catest = new ClassATest();
catest.Display();
}
}

------------------------------------------------------------------------------------

In the ClassBTest i define the Main method and make an object reference of ClassATest and call its method.

The screen given below describe how to compile this programs.


Multiple Classes In Multiple Files Multiple Classes In Multiple Files Reviewed by Baljeet Singh on 08:55 Rating: 5

No comments:

Powered by Blogger.