View Full Version : C# - static
When do we use static in c#?
I'm reading a book and i see this
static int val;
or
static void ShowDouble(){
...
}
But why do you use static en why don't you just write for example int val; ?
BLiZZaRD
04-27-2010, 07:52 PM
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/library/98f28cdx%28VS.71%29.aspx
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#
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.