none
Partial Class RRS feed

  • General discussion

  • ??

    What is partial class and why it Required ?


    Thanks . Rajesh Kumar email-Id :rkumar1904@hotmail.com

    Friday, July 5, 2013 6:53 AM

All replies

  • A partial class is used when you want to split the defintion (code) of a class over more than one source file: http://msdn.microsoft.com/en-us/library/wa80x488(v=vs.80).aspx
    Friday, July 5, 2013 6:58 AM
  • Hi,

    it's true that when we need to split the code over more than two source files then we can use partial class.

    So we should be aware of the situations when we need to do so or where it is used:

    1. When your code should provide the skelton of class definition and rest of the code is generated dynamically by compiler/some other engine, as happens in asp.net web forms, since your code behind is partial, you are providing only custom methods and page life cycle event handlers. But behind the scenes there needs more things to happen to initiate and complete the web request. Since that code is really complex and also need not to be written each time by us, that is generate by the compiler/some other engine, at later stage, which is also partial.

    2. When we need to do parallel implementation of source code by more than one developer.

    The link provided by Magnus is sufficient I think.

    Let me know if you still need any help.


    One good question is equivalent to ten best answers.

    Monday, July 8, 2013 6:23 AM