Results 1 to 3 of 3

Thread: C# - static

  1. #1
    Join Date
    Feb 2009
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question C# - static

    When do we use static in c#?

    I'm reading a book and i see this
    Code:
    static int val;
    or
    Code:
    static void ShowDouble(){
    ...
    }
    But why do you use static en why don't you just write for example int val; ?

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Use the static modifier to declare a static member, which belongs to the type itself rather than to a specific object. The static modifier can be used with fields, methods, properties, operators, events and constructors, but cannot be used with indexers, destructors, or types.
    From: http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Feb 2009
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I found the same yesterday, but can someone explain it with his own words?

    edit:
    Found more information on this site:
    http://www.daniweb.com/forums/thread96978.html#
    Last edited by NDK; 04-28-2010 at 12:29 PM. Reason: found more info on site

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •