what are partial classes and their use?

Answers were Sorted based on User's Feedback



what are partial classes and their use?..

Answer / dasharatham

This is a feature of 2005,when we have large and unwildly
classes instead of writing all the methods in same program
we will divide the class into number of programs with the
same class name,these classes are preceeded with partial
keyword,when we compile all this partial classes only one
dll with the same class name will be created.


class with some 20 methods:
Example.cs
class classA{
m1( );
m2( );
.
.
.
m20( );
}

Apply partial concept:

Example1.cs
partial class classA
{
m1( );
m2( );
.
.
m8( );
}
example2.cs
partial class classA
{
m9( );
m10( );
.
.
m15( );
}
Example3.cs
partial class classA
{
m16( );
.
.
m20( );
}

if we compile Examle1.cs,Example2.cs,Example3.cs it will
create only one dll

Is This Answer Correct ?    3 Yes 2 No

what are partial classes and their use?..

Answer / vikas kant

Partial Class is the class whose definition is present in
two or more files.All these files combined with each other
at the compile time.
e.g :---

public partial class Employee
{
public void DoWork()
{
}
}

public partial class Employee
{
public void GoToLunch()
{
}
}

so while using the partial classes coders can work in
different files and at compile time all the code can be
combined.it saves the time and also provides the better
security bcoz code is present in more than one file.

Is This Answer Correct ?    1 Yes 0 No

what are partial classes and their use?..

Answer / arunajyothi.m

“partial” keyword can be used to split a single class,
interface, or struct into multiple, separate files in
ASP.NET (using C# as the language). This permits multiple
developers to works on these files, which can later be
treated as a single unit by the compiler at the time of
compilation and compiled into MSIL code.

1.Partial classes can improve code readability and
maintainability by providing a powerful way to extend the
behavior of a class and attach functionality to it.

2.The partial modifier can only appear immediately before
the keywords class, struct, or interface.

3.Nested partial types are allowed in partial-type
definitions.

4.Using partial classes helps to split your class
definition into multiple physical files.

5.Note that the partial keyword applies to classes,
structs, and interfaces, but not enums

Is This Answer Correct ?    3 Yes 4 No

Post New Answer

More ASP.NET Interview Questions

i cant get Primary output selection from the Dialog box While Creating Setup and Deployment the web application how to solve it..

1 Answers  


Describe the application event handlers in ASP.NET?

0 Answers   HCL,


Difference between Active Exe and Dll ?

3 Answers   Satyam,


I M working in 1.1 .net framework. In a page I have 5 text box & 2 data grid. In PageLoad() All text box will populate with blank value & 1st dataGrid with some value. When I click on EDIT button Of the 1st dataGrid,The Relevent data Of the particular row will populate in first 3 textboxs & corresponding relevent data Will populate in the 2nd DataGrid. Now when I click 2nd datagrid's EDIT button of a perticular Row,relevent data will populate on last 2 textboxs & 1st 3 textbox's value will be same as per as it was........ ........My Problem Is ........... When I click on edit button Of 2nd DataGrid, 1st 3 text boxes values goes Off & 2nd DataGrid Is goes off Due to Postback.but The relevent value is populated In last 2 textboxes.So How I stoped this postback??So that all the data in 1st 3 textboxes will be same.So that I can edit the values of 2nd Grid with 1st 3 textBoxes value.. plz dirctly mail me 1 copy of post to... maloy.adhikari@in.com

2 Answers  


How does u call and execute a sp in .net?

0 Answers  






Your ASP.NET application displays sales data on a page. You want to improve performance by holding the page in memory on the server for one hour. You want to ensure that the page is flushed from memory after one hour, and that the page is re-created when the next request for the page is received. What should you do? A . Initialize a new instance of the Cache class in the Application.Start event handler. B . Initialize a new instance of the Timer class in the Page.Load event handler. C . Set the Duration attribute of the OutputCache directive in the page. D . In the Web.config file, set the timeout attribute of the sessionState element.

5 Answers   ADITI, Syntax Softtech,


Do I need to have the latest version of windows media player installed?

0 Answers  


About Postback ?

6 Answers   Accenture,


What is CSS? What is the advantage os using CSS in ASP.NET Web Applications?

2 Answers   PCS,


Why Web Services?

1 Answers  


What are ASP.NET Web Forms? How is this technology different than what is available though ASP (1.0-3.0)?

1 Answers  


How can we add an event handler for a ASP.NET function executed on MouseOver for a certain button.

0 Answers   Siebel,


Categories