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

C#

 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova17-Jul-12 4:01
BobJanova17-Jul-12 4:01 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
DaveyM6917-Jul-12 10:31
professionalDaveyM6917-Jul-12 10:31 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova18-Jul-12 2:26
BobJanova18-Jul-12 2:26 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
DaveyM6918-Jul-12 4:52
professionalDaveyM6918-Jul-12 4:52 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova18-Jul-12 6:31
BobJanova18-Jul-12 6:31 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova17-Jul-12 4:05
BobJanova17-Jul-12 4:05 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
Matt T Heffron17-Jul-12 8:07
professionalMatt T Heffron17-Jul-12 8:07 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova18-Jul-12 2:19
BobJanova18-Jul-12 2:19 
It will guarantee it if the person writing the code respects the interface – which considering he has access to the source of Foo is all you can rely on anyway.

Putting the singleton code inside the class means that it is duplicated in every class that you want Singleton behaviour for. I prefer to rely on an intelligent developer and avoid code duplication. This is a similar approach to that taken by dependency injection frameworks, where you still can manually create objects, but you are trusted not to do so if it's inappropriate.

In fact invoking your Singleton implementation twice will create a new instance each time!

Now that I believe not to be the case, since Singleton<T>.Instance checks for the existence of an instance (in fact that is the entire purpose of the Singleton class).
Edit: though I had forgotten to declare the instance field and property static D'Oh! | :doh:

modified 18-Jul-12 8:27am.

GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
Matt T Heffron24-Jul-12 8:04
professionalMatt T Heffron24-Jul-12 8:04 
QuestionHow to find API's to generate barcodes in C# Pin
Akshay_8816-Jul-12 21:10
Akshay_8816-Jul-12 21:10 
AnswerRe: How to find API's to generate barcodes in C# Pin
Richard MacCutchan16-Jul-12 21:31
mveRichard MacCutchan16-Jul-12 21:31 
AnswerRe: How to find API's to generate barcodes in C# Pin
Peter_in_278016-Jul-12 21:36
professionalPeter_in_278016-Jul-12 21:36 
GeneralRe: How to find API's to generate barcodes in C# Pin
Akshay_8816-Jul-12 23:37
Akshay_8816-Jul-12 23:37 
GeneralRe: How to find API's to generate barcodes in C# Pin
Peter_in_278017-Jul-12 1:22
professionalPeter_in_278017-Jul-12 1:22 
GeneralRe: How to find API's to generate barcodes in C# Pin
Akshay_8817-Jul-12 1:29
Akshay_8817-Jul-12 1:29 
GeneralRe: How to find API's to generate barcodes in C# Pin
Dave Kreskowiak17-Jul-12 1:33
mveDave Kreskowiak17-Jul-12 1:33 
GeneralRe: How to find API's to generate barcodes in C# Pin
Akshay_8817-Jul-12 1:41
Akshay_8817-Jul-12 1:41 
GeneralRe: How to find API's to generate barcodes in C# Pin
Dave Kreskowiak17-Jul-12 2:11
mveDave Kreskowiak17-Jul-12 2:11 
GeneralRe: How to find API's to generate barcodes in C# Pin
Akshay_8817-Jul-12 2:19
Akshay_8817-Jul-12 2:19 
QuestionRe: How to find API's to generate barcodes in C# Pin
Richard MacCutchan17-Jul-12 2:44
mveRichard MacCutchan17-Jul-12 2:44 
AnswerRe: How to find API's to generate barcodes in C# Pin
Akshay_8817-Jul-12 19:24
Akshay_8817-Jul-12 19:24 
GeneralRe: How to find API's to generate barcodes in C# Pin
Richard MacCutchan17-Jul-12 21:29
mveRichard MacCutchan17-Jul-12 21:29 
AnswerRe: How to find API's to generate barcodes in C# Pin
Luc Pattyn17-Jul-12 2:52
sitebuilderLuc Pattyn17-Jul-12 2:52 
AnswerRe: How to find API's to generate barcodes in C# Pin
DaveyM6920-Jul-12 8:05
professionalDaveyM6920-Jul-12 8:05 
QuestionC# files missing .cs file Pin
Member 906602516-Jul-12 20:33
Member 906602516-Jul-12 20:33 

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.