Important Link :-
If we make the constructor private in the class using C#,
then we can’t perform following thing as below:-
Example:-
namespace ConsoleApplication1
{
public class car
{
private car();
}
class Program
{
static void Main(string[] args)
{
car c = new car(); // car.car() is
inaccessable due to its protection
level
}
}
}
Example :-
public class car
{
private car(){}
public void
GearSystem() { }
}
public class Maruti : car // car.car() is inaccessable due to its protection level
{
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.