Virendradugar: What Is A Private Constructor? Where Will You Use It?
Virendradugar: What Is A Private Constructor? Where Will You Use It?
Virendradugar: What Is A Private Constructor? Where Will You Use It?
If you declare a Constructor as private then it doesn’t allow to create object for its derived class,
i.e you loose inherent facility for that class.
Hope this helps!!!!!
What is Overriding?
Posted by: Raja
Method overriding is a feature that allows to invoke functions (that have the same signatures)
and that belong to different classes in the same hierarchy of inheritance using the base class
reference. In C# it is done using keywords virtual and overrides .
1)Class
2)Object
3)Inheritance
4)Polymorphism
5)Abstraction
6)Encapsulation
-----------------------------------------------------
Advantages:
1)Code reusability: define a class and n number of objects implement the class
logic: example: Button class and n number of Button objects
2)Inheritance : Eliminates redundant code and extend the use of existing classes.
example: 1)we can create our own TextBox by inheriting from the TextBox class.
2)We can inherit one Windows Frorm into another.
3)Encapsulation: The programmer can hide the data and functions in a class from other
classes.It is accomplished through modifiers like private, protected,
protected internal.
4)Easy to Maintain and Upgrade:
If we want to make changes in a class, we can make them and save the changes in the .dll This
.dll can easily be updated in the client by using Update Reference.
ex:
Console.WriteLine("welcome");
Console.WriteLine(100);
encapsulation, inheritance
Object:
int calc(int a)
{
return a;
}
double calc(double b)
{
return b*5;
}
Uses:
Structures are typically used for handling
small amounts of data or where inheritance, overriding is not required
example: int a=100;
Class
ex:
class abc:demo
{
--Wrong
}
2)They can contain static as well as nonstatic members.
static classes:
ex:
static class Program
{
A class has default modifiers as Internal . It can declare members (methods etc) with following
access modifiers:
public
internal
private
protected internal
A methods, fields, and properties has default access modifier as "Private" if no modifier is
specified.
What is "this"
If no constructor defined then the CLR will provide an implicit constructor which is called as
Default Constructor.
A class can have any number of constructors provided they vary with the number of arguments
that are passed, which is they should have different signatures.
Can we specify the access modifier for explicitly implemented interface method?
What is Class?
The keyword class in C# indicates that we are going to define a new class (type of object)
What is Object?
What is Polymorphisms?