OOPs
Hello geeks after a long gap I come back with a very arousing blog. When ever you see .Net Framework or any Microsoft patterns & practices library configure, they allow the developer to load the external components through some configurations in Web.config or App.Config file and that will be later called by the framework at runtime. Ok let take an example of Microsoft.Practices.Enterpr... Interface that require to format a LogEntry in a way suitable for...
According to C# specification interface contain a signature of events but a complete and brief implementation of events through interface is not available on the net. First you identify the interface public interface IControl { // Raise this event. event EventHandler OnCommand; } According to my need I create a class that inherit from System.EventArgs public class CommandArgs : EventArgs { public string CommandName; } My OutCommand class is a implementation of IControl interface that contain an OnCommand...
My following class is a complete C# class because its contain all possible declarations. using System; class MyClass { public const int MyConst = 45; public int MyField = 64; public static int MyStaticField = 65; public void MyMethod() { Console.WriteLine("MyClass.... call"); } public int MyProperty { get { return MyField; } set { MyField = value; } } public event EventHandler MyEvent; public int this[int index] { get { return 0; } set { Console.WriteLine("this[{0}] = {1}", index, value); }...
This is my C# class and its compatible with all .Net framework versions. public class Person { // Fields private string _name; private int _age; private string _city; private string _company; // Properties public string Name { get { return _name; } set { _name = value; } } public int Age { get { return _age; } set { _age = value; } } public string City { get { return _city; } set { _city = value; } } public string Company { get { return _company; } set { _company = value; } } } From the last bit...
In this blog I want to describe you three ways how to write singleton class that is thread safe. First Classpublic sealed class TSSingleton{private static volatile TSSingleton instance = null;private static object syncObj = new object();// make the default constructor private,// so that no can directly create it.private TSSingleton(){}// public property that can only get// the single instance of this class.public static TSSingleton Instance{get {// only create a new instance if one doesn't already...