1. When working on large projects, spreading a class over separate files enables multiple programmers to work on it at the same time.
2. When working with automatically generated source, code can be added to the class without having to recreate the source file. Visual Studio uses this approach when it creates Windows Forms, Web service wrapper code, and so on. You can create code that uses these classes without having to modify the file created by Visual Studio.
Is it possible to create partial structs, interfaces and methods?
Yes, it is possible to create partial structs, interfaces and methods. We can create partial structs, interfaces and methods the same way as we create partial classes.
Will the following code compile?
using System;
namespace PartialClass
{
public partial class Student
{
public void Study()
{
Console.WriteLine("I am studying");
}
}
public abstract partial class Student
{
public void Play()
{
Console.WriteLine("I am Playing");
}
}
public class Demo
{
public static void Main()
{
Student StudentObject = new Student();
}
}
}
No, a compile time error will be generated stating "Cannot create an instance of the abstract class or interface "PartialClass.Student". This is because, if any part is declared abstract, then the whole class becomes abstract. Similarly if any part is declared sealed, then the whole class becomes sealed and if any part declares a base class, then the whole class inherits that base class.
Can you create partial delegates and enumerations?
No, you cannot create partial delegates and enumerations.
Can different parts of a partial class inherit from different interfaces?
Yes, different parts of a partial class can inherit from different interfaces.
Can you specify nested classes as partial classes?
Yes, nested classes can be specified as partial classes even if the containing class is not partial. An example is shown below.
class ContainerClass
{
public partial class Nested
{
void Test1() { }
}
public partial class Nested
{
void Test2() { }
}
}
My Blog List
Sponser Link
know more info pls click here
Subscribe to:
Post Comments (Atom)
Popular Posts
-
<div id="editable" contenteditable="true"> text text text<br> text text text<br> text text...
-
1. Use exception-handling structures to deal with exceptions within the scope of a procedure. This technique is called structured exception ...
-
There is a little tool called JSPExecutor that allows you to do just that. The developers (Hendrik Schreiber <hs@webapp.de> & Pet...
-
The Trace object provides the Write and Warn methods to allow you to write messages to a request’s trace information. The two methods are id...
-
Let me explain the process; 1. First you should go to your adsense account and grab the code for your adsense ads. 2. For this you sh...
-
Few know that those who have web hosting are at the same time endowed with a free VPN (Virtual Private Network, a very safe connection to t...
-
There are a number of ways to get information about a particular Linux command. Chances are you are using bash shell which is currently the...
-
To check if a URL or an email address is valid, the common solution is regular expressions. For instance, to validate an email address in P...
-
we are running a classified site and the latest ads which are coming to the system is indexed in solr write server in every three minutes. T...
-
open source Apache webserver is well-proven, but can still offer an administrator headaches from timeto time when things don't go quite ...
0 comments:
Post a Comment