CAN WE MAKE A PROGRAM HAVING STRUCTURE OR CLASS UNDER STRUCTURE?

Abhishek Srivasatava

Total Post:70

Points:350
Posted by  Abhishek Srivasatava
C#  .NET  Class  Struct 
C#
 251  View(s)
Ratings:
Rate this:
  1. Abhishek Srivasatava

    Post:70

    Points:350
    Can we make a program having structure or class under structure?

    Yes, we can make a program having structure or class under structure.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
     
    namespace ConsoleApplication14
    {
        struct demo
        {
        
            public void fun1()
            {
                demo2 d2 = new demo2();
                demo3 d3 = new demo3();
          
                d2.fun2();
                Console.WriteLine("structure under structure is implemented successfully");
                d3.fun2();
                Console.WriteLine("structure under class  is implemented successfully");
            }
            struct demo2
            {
                public void fun2()
                {
                    Console.WriteLine("Testing Comment");
                }
            }
            class demo3
            {
                public void fun2()
                {
                    Console.WriteLine("Testing Comment");
                }
            }
           
          
        }
        class Program     {
     
            static void Main(string[] args)
            {
                demo d1 = new demo();
                d1.fun1();
                demo2 d2 = new demo2();
                demo3 d3 = new demo3();
     
                d2.fun2();
                Console.WriteLine("Class under structure is implemented successfully");
                d3.fun2();
                Console.WriteLine("Class under class is implemented successfully");
     
                Console.ReadLine();
               
            }
            struct demo2
            {
                public void fun2()
                {
                    Console.WriteLine("Testing Comment");
                }
            }
            class demo3
            {
                public void fun2()
                {
                    Console.WriteLine("Testing Comment");
                }
            }
           
        }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!