HI ,
What is inner and nested class in c#?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted May 13, 2013, 1:12 AM
hi,
Whenever i need encapsulate a format of data that is primarily going to be used within the parent class at this time i proffered to use inner or nested class.
also there are several other reason in architecture design to used nested classes.
1) for Logically grouping
2) increases encapsulation level.
3)it is more readable and maintainable code.
hope this will help you.
Ajitender VijayPosted May 13, 2013, 12:49 AM
Jignesh TrivediPosted May 13, 2013, 12:07 AM
Nested classes are nothing but class with in class or we can say the class declaration is fully contained with the other class declaration.
example
public class baseClass
{
// This is the nested class
private class NestedClass
{
// implement NestedClass.
}
//Declare property/ method of base class.
}
Inner class are private and tightly bind or couple with their parent class.
hope this will help you.
VulpesPosted May 12, 2013, 9:10 AM
'Type' for this purpose means either a class or a struct.
Structs can also be nested or top level as defined above.
Satyapriya NayakPosted May 12, 2013, 5:26 AM
http://www.codeproject.com/Articles/20628/A-Tutorial-on-Nested-Classes-in-C