I know, I should probably have a separate page for XML and C#, but friends trust me there are plenty out there and I’d very much not like to simply copy and paste it all, rather to share URLs. The resources that helped me most were [drum-roll] MSDN & W3Schools.com (http://xmlmaster.org is also a strong competitor though – IMO )
How do you make an instance of an object globally available and guarantee that only one instance of the class is created?
Per MSDN, to ensure that only a single instance of a class can exist, you must control the instantiation process. This implies that you need to prevent other objects from creating an instance of the class by using the instantiation mechanism inherent in the programming language (for example, by using the new operator). The other part of controlling the instantiation is providing a central mechanism by which all objects can obtain a reference to the single instance. (MSDN)
Singleton provides a global, single instance by:
Making the class create a single instance of itself.
Allowing other objects to access this instance through a class method that returns a reference to the instance. A class method is globally accessible.
Declaring the class constructor as private so that no other object can create a new instance. ( and this should also make it thread-safe ! )
The explicit keyword declares a user-defined type conversion operator that must be invoked with a cast. Where as the implicit keyword is used to declare an implicit user-defined type conversion operator. Use it to enable implicit conversions between a user-defined type and another type, if the conversion is guaranteed not to cause a loss of data.
How many times you have to bullet proof your application against some bad or junk data ? Sometimes we might not have anticipated some scenario until quite a while. And this can quite possible if your application relies on some other program ( data from web service, some sort of incoming XML or something like that )
Well LINQ is your friend !
Just a heads up :
Going forward I shall try to maintain all string manipulation related posts ALSO under ‘string-manipulation‘ tag, just if that helps you drill down the content better. Cheers ! 😉
Scenario : At the time of consuming data from another application or program, one of the frequent issue is data in and data out ! I was working for similar scenario the other day where a flat was generated and then another program had lexical parser and would generate tokens etc. Long story short, in a typical workflow we had blank lines and they were causing issue. Very simple issue … once this stupid thing is identified and verified being the actual culprit !