Home > Software > .NET > Dot-Net
Interview Questions   Tutorials   Discussions   

Dot-Net - What are partial classes?




215
views
asked mar October 5, 2014 02:33 PM  

What are partial classes?


           

1 Answers



 
answered By siddhant   0  

Partial classes span multiple files. How can you use the partial modifier on a C# class declaration? With partial, you can physically separate a class into multiple files. This is often done by code generators.

Program that uses partial class: C#

class Program
{
    static void Main()
    {
    A.A1();
    A.A2();
    }
}

Contents of file A1.cs: C#

using System;

partial class A
{
    public static void A1()
    {
    Console.WriteLine("A1");
    }
}

Contents of file A2.cs: C#

using System;

partial class A
{
    public static void A2()
    {
    Console.WriteLine("A2");
    }
}

Output A1 A2

flag   
   add comment

Your answer

Join with account you already have

FF

Preview

 Write A Tutorials
Online-Classroom Classes
www.writeabc.com


  1 person following this question

  1 person following this tag

  Question tags

Asked 2 years and 3 months ago ago
Number of Views -215
Number of Answers -1
Last updated
3 years and 2 months ago ago

Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert