Sealed Class:
*A sealed class does not allow classes to derive from it.
*Classes are more often marked sealed to prevent accidental inheritance.
*You cannot create a new protected member in a sealed class.
Static Class:
* A static class cannot be instantiated. It is called like calssname.method( )
* A static class contains only static members.
* Is sealed.
* They cannot have constructor, although we can still declare a static constructor.
Boxing and Unboxing:
Boxing and Unboxing are the processes that enable value type(eg: int) to be treated as reference types.
Boxing is implicit conversion of value type to type object.Usually value types are stored in stack.When value types are converted into objects, it gets stored in heap.
eg: int i = 123;
object o = i;
Boxing is implicit.
Unboxing:
To return the boxed object back to a value type you must explicitly unbox it.
eg: int i= 123;
object o = i; //Up-to this is boxing
int j = ( int )o; //Explicit conversion Unboxing.
Structs:
A struct is a simple user-defined type,a lightweight alternative to classes.
Structs are similar to classes in that they have propertties,methods,fields etc.
Difference between classes and structs
Structs dont support destructors and inheritance.
A class is a reference type whereas a struct is a value type.
Multiple Inheritance:
Multiple inheritance is the feature in which a class can inherit behaviour and features of more than one super class.
Why C# does not support multiple inheritance?
It is because multiple inheritance adds too much complexity to the languafe while providing too little benefit.
Difference between stack and heap
Stack memory is referred to as temporary memory. If you come out of the program, the memory of the variable will no more be there.Used for local variables.
Heap memory is referred to as Permanent memory. Memory allocated for the object will be maintained even if we came out of the program.
Retrieving second table in Datareader
In dataset we can use ds.tables(1) and in datareader we can use dr.NextResult()
*A sealed class does not allow classes to derive from it.
*Classes are more often marked sealed to prevent accidental inheritance.
*You cannot create a new protected member in a sealed class.
Static Class:
* A static class cannot be instantiated. It is called like calssname.method( )
* A static class contains only static members.
* Is sealed.
* They cannot have constructor, although we can still declare a static constructor.
Boxing and Unboxing:
Boxing and Unboxing are the processes that enable value type(eg: int) to be treated as reference types.
Boxing is implicit conversion of value type to type object.Usually value types are stored in stack.When value types are converted into objects, it gets stored in heap.
eg: int i = 123;
object o = i;
Boxing is implicit.
Unboxing:
To return the boxed object back to a value type you must explicitly unbox it.
eg: int i= 123;
object o = i; //Up-to this is boxing
int j = ( int )o; //Explicit conversion Unboxing.
Structs:
A struct is a simple user-defined type,a lightweight alternative to classes.
Structs are similar to classes in that they have propertties,methods,fields etc.
Difference between classes and structs
Structs dont support destructors and inheritance.
A class is a reference type whereas a struct is a value type.
Multiple Inheritance:
Multiple inheritance is the feature in which a class can inherit behaviour and features of more than one super class.
Why C# does not support multiple inheritance?
It is because multiple inheritance adds too much complexity to the languafe while providing too little benefit.
Difference between stack and heap
Stack memory is referred to as temporary memory. If you come out of the program, the memory of the variable will no more be there.Used for local variables.
Heap memory is referred to as Permanent memory. Memory allocated for the object will be maintained even if we came out of the program.
Retrieving second table in Datareader
In dataset we can use ds.tables(1) and in datareader we can use dr.NextResult()
No comments:
Post a Comment