Saturday, 18 June 2011

C# - Singleton Class using Lazy <T> in Dotnet .40

Code Snippet,

public sealed class Singleton
{
private static readonly Lazy lazy =
new Lazy(() => new Singleton());

public static Singleton Instance { get { return lazy.Value; } }

private Singleton()
{
}
}

Reference:-http://csharpindepth.com/Articles/General/Singleton.aspx

5 comments:

  1. Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.
    Vee Eee Technologies| Vee Eee Technologies|

    ReplyDelete
  2. Replies
    1. Yes,as long as declaration is with 'static' .

      Delete

  3. http://b2bad.in/Packers-and-Movers-in-Noida/ @ Noida packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Delhi/ @ Delhi packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Gurgaon/ @ Gurgaon packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Faridabad/ @ Faridabad packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Indirapuram-Ghaziabad/ @ Ghaziabad packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Mumbai/ @ Mumbai packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Chennai/ @ Chnnai packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Bangalore/ @ Bangalore packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Pune/ @ Pune packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Hyderabad/ @ Hyderabad packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Kolkata/ @ Kolkata packers and Movers

    http://b2bad.in/Packers-and-Movers-in-Jaipur-Rajasthan/ @ Jaipur packers and Movers

    ReplyDelete
  4. http://b2bad.in/Packers-and-Movers-in-Delhi/ @ Movers and packers in Delhi http://b2bad.in/Packers-and-Movers-in-Delhi/ @ Delhi packers and movers

    ReplyDelete