C# program to Show the example of new keyword


C# program to Show the example of new keyword


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

using System.Threading;

using System.IO;


namespace Program

{

    class Function1      // Creating class "Function1"

    {

        public void PrintData() //create Function

        {

            Console.WriteLine("This is Function1 Body");

        }

    }

    class Function2     // Creating class "Function2"

    {

        public void PrintData()  //Create Function

        { 

            Console.WriteLine("This is Function2 Body");

        }

    }

    class AkbTechie

     {

            static void Main(string[] args)

                {

                    // Creating the obejcts of Both Class with the help of new keyword

                    Function1 F1 = new Function1();

                    Function2 F2 = new Function2();


                    // Calling the member function of both Class

                    F1.PrintData();

                    F2.PrintData();

                    Console.ReadKey();           

                }

    }

}

output:-

This is Function1 Body

This is Function2 Body


एक टिप्पणी भेजें

0 टिप्पणियाँ