what are partial classes?

Answers were Sorted based on User's Feedback



what are partial classes?..

Answer / chaitanya.k

Partial classes is a new feature of OOPs in .NET2.0

Partial classes means split the class into multiple files.


For example

u r working with windows applications actually
designer.cs is using a class like webform1, u can use this
class in other cs file also.

Is This Answer Correct ?    59 Yes 13 No

what are partial classes?..

Answer / anna

using a partial class, we can split a class into multiple
files.
compiler will treat them as different classes.
but when compiled all the files will be treated as a single
class.
it is more efficeint

Is This Answer Correct ?    45 Yes 7 No

what are partial classes?..

Answer / sridhar.venkataramanan

File 1.
partial class Employee
{
string employeename;
public void getEmployeeName(string empname)
{
employeename = empname;
}

public static void Main()
{

Employee objEmployee = new Employee();
objEmployee.getEmployeeName("Krish");
objEmployee.showEmployeeName();
Console.ReadLine();
}

}
File 2

partial class Employee
{
public void showEmployeeName()
{
Console.WriteLine("Name --->" + employeename);
}

}

Even though the method showEmployeeName is not a available
in file 1 since its partial class the complier would
combine the fragments of the file that corresponds to same
class.

Is This Answer Correct ?    28 Yes 6 No

what are partial classes?..

Answer / kamlesh sharma

through partial keyword we can split the defination of the
class in different source files and these definations are
combined when application is compiled.

it may be helpful in large projects,so many people can work
on same class

Is This Answer Correct ?    20 Yes 5 No

what are partial classes?..

Answer / rashmi tiwari

One of the greatest benefits of partial classes is that it
allows a clean separation of business logic and the user
interface (in particular the code that is generated by the
visual designer). Using partial classes, the UI code can be
hidden from the developer, who usually has no need to
access it anyway. Partial classes will also make debugging
easier, as the code is partitioned into separate files.

Is This Answer Correct ?    22 Yes 8 No

what are partial classes?..

Answer / sharif

Can you u explain me the code for the partaial class?

Is This Answer Correct ?    10 Yes 7 No

what are partial classes?..

Answer / anil

Partial class is th one feature in V2.0 where you can split
the functionalty of the single file in multiple files.

This is helpful on working simultaneously on same file,
clearly separates Business Logic and UI, separets logic
from single file to multiple files.

File1
Imports system
Interface IPartialInterface

sub abc( byval str as string)
sub abc()
End interface

Partial Class DemoPartialClass
dim strName a string
strName = "Anil"
Response.Write(strName)
End Class

File2

Imports system
Implements IPartialInterface

Partial Class DemoPartialClass
Public sub abc(ByVal strName as string)
Dim strValue as string
strValue = strName
End Sub
End Class

File 3

Imports system
Implements IPartialInterface

Partial Class DemoPartialClass
public sub abc()
response.write(strName)
End Sub
End Class

Is This Answer Correct ?    3 Yes 0 No

what are partial classes?..

Answer / sunny setia

The purpose of partial classes is to allow a class's
definition to span across multiple files. It is especially
useful for:

Allowing multiple developers to work on a single class at
the same time without the need for later merging files in
source control.

Allowing a separation between the class interface and the
implementation-related definitions

Easing the writing of code generators, such as visual designers.

Is This Answer Correct ?    5 Yes 4 No

what are partial classes?..

Answer / zahid nawaz

Partal classes can help in segregating code with respect
type like tool visual Studio generated,default imported
namespaces , events registration , variable declaration
code etc. It is best to split lengthy code into smaller
units but dealing them with same class Object

Is This Answer Correct ?    9 Yes 9 No

what are partial classes?..

Answer / rita ghosal

partial class is a incomplete class

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Dot Net Framework Interview Questions

Describe the .net framework architecture.

0 Answers  


Explain the use of Inversion of control (IOC)?

0 Answers  


I want to fetch data from datareader. i have three tables in datareader. i want to bind my two table with datagrid, then i want to fetch a value from my third table. do u have any idea pls help me. we use dr.nextresult() for multiple tables.

0 Answers  


What are the derived classes from xmlReader and xmlWriter

1 Answers  


What are the new features 3.5 framework against with the tool?

0 Answers  






What is the benefit of entity framework?

0 Answers  


What is MSIL, IL, CTS?

13 Answers  


Explain ASP.NET MVC Identity and Security?

0 Answers  


What is the role of the jit compiler in .net framework?

0 Answers  


What is JIT and how is works ?

10 Answers  


Explain the request flow in asp.net mvc framework?

0 Answers  


can we call the garbage collector to run explicicitly?

6 Answers   Kanbay, Volvo,


Categories