what are partial classes?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 Non Action methods in ASP.Net MVC?
Can you explain renderbody and renderpage in mvc?
mention what is csdl, ssdl and msl sections in an edmx file?
What is the CLS
What “beforFilter()”,“beforeRender” and “afterFilter” functions do in Controller?
Is there built-in support for tracing/logging
What are bundling & minification features in asp.net mvc 4?
Explain the advantages and disadvantages of ASP.Net MVC over ASP.NET?
What are the types of assemblies and where can u store them and how ?
11 Answers Accenture, BirlaSoft, IBM,
What is objectset? : Entity framework
i want to take the fast track training on >net Frame work and work flows and share point could you tellme the good institutes for that cources
In which testing using in .net framwork?