GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  Microsoft.NET
Go To First  |  Previous Question  |  Next Question 
 Microsoft.NET  |  Question 33 of 38    Print  
what is the concept of partial class in .net2.0?

  
Total Answers and Comments: 1 Last Update: June 13, 2007     Asked by: Somnath Das 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Rajesh Bathala
 

Partial class allows developers to split a class into multiple files.


ex:

public partial class A
{
    A()
   
    {
        //constructor here

    }

}

Suppose another developer needs to add a new function to it called updated A , the other developer can creat a new file call it A1.cs and it should be look something like this.

public partial cllass A

{
  public void update A()
  {
     // function code goes here
    }
}


while using partial classes ,if we have declared a constructor or a function in one source file, we can not define the same in the other partial source file.

  The .NET runtime executes  these two classes it treats  two or multiple source file as one single class A.


Regards

Rajesh Bathala

Above answer was rated as good by the following members:
rambabu_ms, prashantneve
June 13, 2007 05:38:06   #1  
Rajesh Bathala        

RE: what is the concept of partial class in .net2.0?

Partial class allows developers to split a class into multiple files.


ex:

public partial class A
{
A()

{
//constructor here

}

}

Suppose another developer needs to add a new function to it called updated A the other developer can creat a new file call it A1.cs and it should be look something like this.

public partial cllass A

{
public void update A()
{
// function code goes here
}
}


while using partial classes if we have declared a constructor or a function in one source file we can not define the same in the other partial source file.

The .NET runtime executes these two classes it treats two or multiple source file as one single class A.


Regards

Rajesh Bathala

 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    

 Related Questions

Latest Answer : 1. Abstract class can have method with implementation, interface can only have method definitions2. You can inherit multiple interface but cannot inherit multiple abstract class ...
Read Answers (4) | Asked by : Prasad
Tags : Abstract

Latest Answer : To support multiple inheritence.As interfaces support multiple inheritance ...
Read Answers (3) | Asked by : Abhijit Khalate

Latest Answer : Partial class allows developers to split a class into multiple files.ex:public partial class A{    A()        {        //constructor here    }}Suppose another ...
Read Answers (1) | Asked by : Somnath Das

How Handle error if interface A,B are extended in class C. If class C using one function that is in A Interface if any error occurs in function how do you handle it? 
Latest Answer : Interfaces can have function body. If the body of the function is provided you can handle the exception in the function in interface A using try catch statements. OR Handle the exception in class C where the function of interface A is called using try ...

How will you access private members of a class without using Reflection? 
Latest Answer : By using deligates ...


 Sponsored Links

 
Related Articles

Microsoft AJAX Library - Introducing JSON

Introducing JSON In AJAX applications client server communication is usually packed in XML documents or in the JSON JavaScript Object Notation format Interestingly enough JSON s popularity increased together with the AJAX phenomenon although the AJAX acronym includes XML mosgoogle JSON is the format
 

Microsoft AJAX Library - Inheritance using Prototypes

Inheritance using Prototypes Once again prototyping can help us implement an OOP feature in a more elegant way than when using closures Prototype based inheritance makes use of the behavior of JavaScript prototypes When accessing a member of a function that member will be looked for in the function
 

Microsoft AJAX Library - Inheritance using Closures

Inheritance using Closures and Prototypes There are two significant techniques for implementing the OOP concept of inheritance with JavaScript code The first technique uses closures and the other technique makes use of a feature of the language named prototyping Early implementations of the Microsof
 

Microsoft AJAX Library - JavaScript Execution Context

JavaScript Execution Context In this section we ll take a peek under the hood of the JavaScript closures and the mechanisms that allow us to create classes objects and object members in JavaScript For most cases understanding these mechanisms isn t absolutely necessary for writing JavaScript code&am
 

Microsoft AJAX Library - Creating Object Members on the Fly

Creating Object Members on the Fly One major difference between OOP in C and ASP NET and OOP in JavaScript is that JavaScript allows creating object members on the fly" This is true for objects and classes that you create yourself and also for JavaScript s own objects and types as well He
 

Microsoft AJAX Library - Associative Arrays

Thinking of Objects as Associative Arrays A key element in understanding JavaScript objects is understanding the notion of associative arrays which are nothing more than collections of key value pairs As a NET developer you have worked with associative arrays represented by classes such as NameValue
 

Microsoft AJAX Library - C# and JavaScript Classes

C and JavaScript Classes For the purpose of demonstrating a few more OOP related concepts we ll use another class Our new class is named Table and it has two public fields rows columns and one method getCellCount The getCellCount method should return the number of rows multiplied by the number of co
 

Microsoft AJAX Library - JavaScript Classes

JavaScript Classes Not only can JavaScript functions contain other functions but they can also be instantiated This makes JavaScript functions a good candidate for implementing the concept of a class from traditional object oriented programming This is very helpful feature indeed because JavaScript
 

Microsoft AJAX Library - Anonymous Functions

Anonymous Functions Anonymous functions can be created adhoc and used instead of a named function Although this can hinder readability when the function is more complex you can do this if you don t intend to reuse a function s code In the following example we pass such an anonymous function to Displ
 

Microsoft AJAX Library - Functions as Variables

Functions as Variables In JavaScript functions are first class objects This means that a function is regarded as a data type whose values can be saved in local variables passed as parameters and so on For example when defining a function you can assign it to a variable and then call the function thr
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape