Leaders snarfblam Posted March 7, 2005 Leaders Posted March 7, 2005 I have a struct named "Screen." By best guess is that my problems are somehow related to a name conflict with the System.Windows.Forms.Screen class. Here is my problem: I have shared (static in c#, i believe) members with initializers in the declaration (Shared i As Integer = 7 / int i = 7; ). I am recieving errors that "initializers on structure members are valid only for constants." When I change the name of the struct, all my errors dissapear... Quote [sIGPIC]e[/sIGPIC]
HJB417 Posted March 7, 2005 Posted March 7, 2005 for structs, intialzing values can only be done in constructors unless the value is declared as a const. Quote
Leaders snarfblam Posted March 7, 2005 Author Leaders Posted March 7, 2005 I thought that shared members were a different case. I changed the name of the struct and the error for the illegal initializers dissapeared. Other errors appeared though because of the reference to a nonexistant type (due to the name change) and must have caused to compiler for some reason to ignore the illegal initializers, hence my confusion. Quote [sIGPIC]e[/sIGPIC]
HJB417 Posted March 7, 2005 Posted March 7, 2005 ya, you're right, though you shouldn't need to change your object name. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.