Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
AnswerRe: Can we overload an abstract method of an abstract class? Pin
Richard Deeming24-Jun-15 7:40
mveRichard Deeming24-Jun-15 7:40 
GeneralRe: Can we overload an abstract method of an abstract class? Pin
NJdotnetdev24-Jun-15 7:52
NJdotnetdev24-Jun-15 7:52 
AnswerRe: Can we overload an abstract method of an abstract class? Pin
maddymaddy1425-Jun-15 19:37
maddymaddy1425-Jun-15 19:37 
QuestionAn abstract singleton factory Pin
Marco Bertschi24-Jun-15 1:48
protectorMarco Bertschi24-Jun-15 1:48 
AnswerRe: An abstract singleton factory Pin
Eddy Vluggen24-Jun-15 2:35
professionalEddy Vluggen24-Jun-15 2:35 
GeneralRe: An abstract singleton factory Pin
Marco Bertschi24-Jun-15 2:48
protectorMarco Bertschi24-Jun-15 2:48 
GeneralRe: An abstract singleton factory Pin
Eddy Vluggen24-Jun-15 8:21
professionalEddy Vluggen24-Jun-15 8:21 
AnswerRe: An abstract singleton factory Pin
Richard Deeming24-Jun-15 4:29
mveRichard Deeming24-Jun-15 4:29 
Marco Bertschi wrote:
What I want to have is a single instance of each and every class deriving from Factory.

The code you've posted won't do that.

Firstly, if you pass anything other than typeof(Factory) to your GetInstance method, you'll get an InvalidOperationException - typeof(DerivedFactory) != typeof(Factory).

Secondly, if you pass typeof(Factory) to your GetInstance method, you'll get a MissingMethodException - you can't create an instance of an abstract class.

Thirdly, even if you fix the previous errors, you would only ever be able to have a single instance of one derived class in a single AppDomain. The static field is specific to the Factory class; you don't get a different copy for each derived class.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


AnswerRe: An abstract singleton factory Pin
Dave Kreskowiak24-Jun-15 5:17
mveDave Kreskowiak24-Jun-15 5:17 
QuestionExtension Methods in .NET 2 Pin
Member 1171394223-Jun-15 20:43
Member 1171394223-Jun-15 20:43 
AnswerRe: Extension Methods in .NET 2 Pin
OriginalGriff23-Jun-15 20:53
mveOriginalGriff23-Jun-15 20:53 
SuggestionRe: Extension Methods in .NET 2 Pin
Richard Deeming24-Jun-15 1:17
mveRichard Deeming24-Jun-15 1:17 
GeneralRe: Extension Methods in .NET 2 Pin
OriginalGriff24-Jun-15 1:34
mveOriginalGriff24-Jun-15 1:34 
GeneralRe: Extension Methods in .NET 2 Pin
Member 1171394224-Jun-15 12:11
Member 1171394224-Jun-15 12:11 
AnswerRe: Extension Methods in .NET 2 Pin
Sascha Lefèvre24-Jun-15 1:09
professionalSascha Lefèvre24-Jun-15 1:09 
GeneralRe: Extension Methods in .NET 2 Pin
Member 1171394224-Jun-15 12:14
Member 1171394224-Jun-15 12:14 
Questionc# question about moving multiple files Pin
elfenliedtopfan523-Jun-15 14:59
elfenliedtopfan523-Jun-15 14:59 
AnswerRe: c# question about moving multiple files Pin
Wes Aday23-Jun-15 15:09
professionalWes Aday23-Jun-15 15:09 
Questionhelp... C# Pin
Member 1177333823-Jun-15 5:08
Member 1177333823-Jun-15 5:08 
AnswerRe: help... C# Pin
Pete O'Hanlon23-Jun-15 5:15
mvePete O'Hanlon23-Jun-15 5:15 
AnswerRe: help... C# Pin
OriginalGriff23-Jun-15 5:55
mveOriginalGriff23-Jun-15 5:55 
QuestionSatellite Assembly Not Working Properly Pin
AmbiguousName23-Jun-15 3:20
AmbiguousName23-Jun-15 3:20 
AnswerRe: Satellite Assembly Not Working Properly Pin
Bernhard Hiller23-Jun-15 4:38
Bernhard Hiller23-Jun-15 4:38 
GeneralRe: Satellite Assembly Not Working Properly Pin
AmbiguousName23-Jun-15 5:49
AmbiguousName23-Jun-15 5:49 
GeneralRe: Satellite Assembly Not Working Properly Pin
Freak3023-Jun-15 23:03
Freak3023-Jun-15 23:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.