Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2005

Tip: Looking for answers? Try searching our database.

Static member variables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Colin Desmond - 25 Nov 2005 22:50 GMT
I have an MFC Extension DLL that I have flicked the /clr switch on and made a
few other tweaks so it compiles and runs in a managed MFC applicaiton.

The DLL contains a number of classes which contain static member variables
and static methods. Are these permitted in a managed DLL?

Thanks

Colin
JAL - 26 Nov 2005 03:30 GMT
Colin... All I can say is that MSIL understands static (class) methods and
variables so that you can certainly declare and use static member methods and
variables in a purely managed language as C#. C# does not support static
local variables. I don't (yet) have any C++/cli code for this so this is C#:

class TestStatic
{
   // static stuff
   private static int uniqueID= 0;
   private static int GetUniqueID()
   {
       lock(typeof(TestStatic))
       {
           return uniqueID++; // returns zero at start
       }
   }

   // member stuff
   private int identity;
   public TestStatic()
   {
       this.identity= TestStatic.GetUniqueID();
   }
   public int Identity
   {
       get
       {
           return identity;
       }
   }
}

> I have an MFC Extension DLL that I have flicked the /clr switch on and made a
> few other tweaks so it compiles and runs in a managed MFC applicaiton.
[quoted text clipped - 5 lines]
>
> Colin
Marcus Heege - 28 Nov 2005 15:16 GMT
I have done quite a lot with /clr so far, and I have not seen problems with
static member variables of native types so far.

Marcus Heege

>I have an MFC Extension DLL that I have flicked the /clr switch on and made
>a
[quoted text clipped - 6 lines]
>
> Colin
Colin Desmond - 29 Nov 2005 20:01 GMT
Marcus,

Thanks for this support, turns out my problems lay elsewhere.

Thanks again

Colin

> I have done quite a lot with /clr so far, and I have not seen problems with
> static member variables of native types so far.
[quoted text clipped - 11 lines]
> >
> > Colin

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.