Private constructor and public parameter constructor -C#
Posted
by Amutha
on Stack Overflow
See other posts from Stack Overflow
or by Amutha
Published on 2010-04-14T18:56:33Z
Indexed on
2010/04/14
19:03 UTC
Read the original article
Hit count: 619
c#
|object-oriented-design
I heard that private constructor prevent object creation from outside world.
When i have a code
public class Product
{
public string Name { get;set;}
public double Price {get;set;}
Product()
{
}
public Product(string _name,double _price)
{
}
}
here still i can declare public constructor(parameter),won't it spoil the purpose of private constructor? When do we need both private and public constructor(parameter) in code?
I need detailed explanation please.
© Stack Overflow or respective owner