crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Simplest definition of partial classes and its rules?
Question Posted on 23 Dec 2020Home >> DotNet >> C# >> Simplest definition of partial classes and its rules?

Simplest definition of partial classes and its rules?
Partial class is usually used to split definition of class in 2 or more classes which should be either in one source code file or in more than one source file. Here we can create class definition in multiple files but these are compiled as only one class at run time. And when we create a instance of this partial class then we can access all methods from source files with same object. So we used "Partial" keyword with all the class names that we want to bind together with the same name of a class in the same namespace. Below image will clarify you the definition of partial class:-


Partial Class
Rules:-
(1)All definition of partial class must be in same seembly and namespace.
(2)All parts have the same accessibility like public or private, etc.
(3)If we declared and part as abstract, sealed or base type then the whole class is declared of the same type.
(4)partial Nested types are allowed.
(5)Different parts can have different base types and so the final class will inherit all the base types.
(6)Partial modifier can only appear immediately before the keywords class, struct, or interface.
(7)Partial methods can be generic or static methods.
(8)Partial methods can have in or ref but not out parameters.
(9)Partial methods are implicitly private methods, so cannot be virtual.
(10)Partial methods must use the partial keyword and must return void.
(11)Partial methods can have in or ref but not out parameters.
0
0



.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions

Simplest definition of partial classes and its rules?

Definition of Tuple class with some examples?

Define Race Condition in cSharp?

C#.Net Reserve Words

can we inherit private class level variables in c#






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap