Quantcast
Channel: C# Constructor - Stack Overflow
Browsing index pages (4 articles)

C# Constructor

I recently saw a C# constructor that look something like this...public Class foo{ public foo() : this(new bar()) {}}Can anybody help me interpret this? where does the bar() fit in?If you could help me...

View Article


Answer by MrTelly for C# Constructor

There will be a second constructor on class foo with a signature like thispublic foo(bar Bar){ ... do something with bar here;}

View Article


Answer by Scott Ferguson for C# Constructor

The foo class should contain another constructor, that takes a bar object as a parameter.public class foo{ public foo() : this(new bar()) { } public foo(bar b) { }}public class bar{}

View Article

Answer by paxdiablo for C# Constructor

This is a common technique to ensure all constructors go through a single point so you only have to change that point (it may have other uses but I'm not aware of them).I've seen it in things that use...

View Article
Browsing index pages (4 articles)


Latest Images