1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

C# Thread

Discussion in 'C#' started by jessysmith1234, Jul 22, 2014.

  1. #1
    How to implement singleton design pattern in C#?How to use nullable types in .Net?
     
    jessysmith1234, Jul 22, 2014 IP
  2. sodevrom

    sodevrom Member

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Hello, well it's pretty easy if you do a google search (for singleton pattern):
    http://csharpindepth.com/articles/general/singleton.aspx

    About nullable types, you cannot define int, double, char as null in C#
    To do that you can use nullable type. This is written like: int? myvar=null;

    This is interpreted like Nullable<int> myvar=new Nullable<int>();

    Good luck!
     
    sodevrom, Jul 29, 2014 IP
  3. BotBuilding

    BotBuilding Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    http://csharpindepth.com/articles/general/singleton.aspx

    Found this.Hope it helps
     
    BotBuilding, Aug 25, 2014 IP
  4. www.gaapps.com

    www.gaapps.com Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    public class Singleton
    {
            private static Singleton instance;
    
            private Singleton()
            {
           
            }
    
            public static Singleton GetInstance()
            {
                    if(instance==null)
                    {
                            instance=new Singleton();
                    }
                    return instance;
            }
    }
    Code (markup):
     
    www.gaapps.com, Aug 30, 2014 IP
  5. ekaddu

    ekaddu Active Member

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #5
    just declare a class as static and you have a class that does similar job as singleton without unnecessary coding.
     
    ekaddu, Feb 7, 2015 IP
  6. zinist

    zinist Banned

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    43
    #6
    How to use nullable types in .Net
    ans:

    Data Types are divided into two catagories
    Value Type :int,float,double
    Reference Type :string ,class
    by default value types are non nullable to make them nullable you can use ?
    int i = null (not possible)
    int ?i= null(possible)
     
    zinist, Jun 27, 2015 IP