Hi,
The reason for this struct is that I wish to assign user information read
from a database at login that will be available to the rest of the forms
throughout the application. I like using structs because it keeps
everything neat and tidy. I am new to programming in C#, I am much more
comfortable with vc++/MFC. Normally I would create a global variable, but
I don't really see, where, how I would do this. If this was a webform app
then I realize I could use a sessionid or use those new profile services. I
am looking for suggestions here. I don't think writing to the registry is
an option.
Anyway any, all help would be appreciated..
thanks,
"Michael Nemtsev" <nemtsev@msn.com> wrote in message
news:9cc1c863861838c821f8f2ae177a@msnews.microsoft .com...[color=blue]
> Hello Rob,
>
> What's the reason to use struct for this?
>
> RD> I have a global structure that I declare within form1.cs, and I
> RD> need to
> RD> reference from within other forms, everything seems to work okay at
> RD> runtime,
> RD> Everything works okay however I get the following warning when I
> RD> compile:
> RD> Warning 2 Accessing a member on 'MYCMS.Form1.GLCurrentUserInfo' may
> RD> cause a runtime exception because it is a field of a
> RD> marshal-by-reference class C:\MYCMS\Form2.cs
> RD> RD> This is my code and how/where I use it..., I'm not sure if I am
> RD> using the correct approach to storing a retreiving variables that I
> RD> require globally..,, if not I am very open to suggestions.
> RD> RD> thanks...
> RD> RD> I create it and make use of it in form1.cs using the folloiw code:
> RD> RD> public struct UserInfo
> RD> {
> RD> public string userid;
> RD> public string password;
> RD> public string userlevel;
> RD> public decimal nemployeeid;
> RD> };
> RD> public UserInfo GLCurrentUserInfo;
> RD> GLCurrentUserInfo.userid = "someUserID";
> RD> RD> then within another form, lets say form2.cs I wish to retreive
> then
> RD> value of it using:
> RD> RD> Form1 oForm = (Form1)ParentForm;
> RD> this.txtAddedBy.Text = oForm.GLCurrentUserInfo.userid;
> ---
> WBR,
> Michael Nemtsev :: blog:
http://spaces.msn.com/laflour
>
> "At times one remains faithful to a cause only because its opponents do
> not cease to be insipid." (c) Friedrich Nietzsche
>
>[/color]