what are the partial class and how we use them please explain in details

Posted by Er.deepakdalal under C# on 4/28/2010 | Views : 1834 | Status : [Member] | Replies : 3
Hi friends


Can any body explain the partial class with example.




Responses

Posted by: Syedshakeer on: 4/28/2010 [Member] Starter

Up
0
Down
Hi,check this link. www.programmersheaven.com/2/Whats-New-in-C-Sharp2-Partial-Class-Definition

Syed Shakeer Hussain

Er.deepakdalal, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenmanam on: 4/29/2010 [Member] Starter

Up
0
Down
In all of the classes we have defined so far, we were using a single file to implement the class. In C#, you can create a class (the same class) in different files. This means that you can start a class in one file and continue it in another file or in other files. This is referred to as partial implementation.

If you have programmed in C++ or C++/CLI, don't confuse its header and source files with C#'s partial implementation of classes. In C++ or C++/CLI, you can include the structure of a class with its member variables (called fields in C#) and the declaration of its methods. In C++, a header file has the extension .h. Here is an example of a C++/CLI header file:
Header File: Cylinder.h


#pragma once


using namespace System;

public ref class CCylinder
{
private:
double rad;
double hgt;

public:
CCylinder(void);
CCylinder(double radius, double height);

property double Radius
{
double get() { return rad; }
void set(double value) { rad = value; }
}

property double Height
{
double get() { return hgt; }
void set(double value) { hgt = value; }
}

double Volume();
};


NaveenKumar

Er.deepakdalal, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 4/29/2010 [Member] Bronze

Up
0
Down


Hi,

Partial Class is the new concept in .net 2.0 , by which a class file with same name can be divided in two class file with partial keyword specfied in any one of the file .

Some of the points of Partial Class are as follows

1) we cannot have same method name with same signatre in two partial class files of the same class name, it gives us a compile time error.
2) at run time the partial class are trated as a single class file

Thanks
Pavan Kumar
Mark Answer if this fits the need

Er.deepakdalal, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response