C# extern int ? How do I make a global var across classes and namespaces ?
Posted
by
dr d b karron
on Stack Overflow
See other posts from Stack Overflow
or by dr d b karron
Published on 2011-01-03T13:46:50Z
Indexed on
2011/01/03
13:53 UTC
Read the original article
Hit count: 233
Dear C#'ers; As an old C/C++ programmer, I want to keep a global int counter across all of MY namespaces and classes.
Public static extern int EventCount;
Is not working; the VS2010 compiler won't let me have an extern int. Even with a DLLImport.
[DllImport ( "SilverlightApplication37.dll" )]
public static extern int EventCount;
VS2010 complains
Error 1 The modifier 'extern' is not valid for this item
so how do i have a global int across all my code ?
Cheers!
dr.K
© Stack Overflow or respective owner