471,330 Members | 1,074 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

Like a Global

I'm reading the Pro C# 2005 and the .Net 2.0 Plataform by Andrew Troelsen
(in time, a nice book!) and a question is in my mind.

Supose that I have a WinForm application that has a login system. With the
login, I take from de DB many user informations that I would use in each
type (premisions for business class, screen options for forms...).

An approach in other OO-Languages is to make a global object "User" with
this informations.

What's the best approach in C# to accomplish this requiriments?

Thanks,

Max
Feb 16 '06 #1
3 1017
Max,

The equivalent would be a static member on a type (preferably public, so
any other class can see it).

However, this isn't really that scalable, so you should be careful when
using it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Max André Bündchen" <no****@microsoft.com> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
I'm reading the Pro C# 2005 and the .Net 2.0 Plataform by Andrew Troelsen
(in time, a nice book!) and a question is in my mind.

Supose that I have a WinForm application that has a login system. With the
login, I take from de DB many user informations that I would use in each
type (premisions for business class, screen options for forms...).

An approach in other OO-Languages is to make a global object "User" with
this informations.

What's the best approach in C# to accomplish this requiriments?

Thanks,

Max

Feb 16 '06 #2
Yes, I had think about that, but in a little large application, I shoud have
problems with pay off.

Thaks for hope.

Max

"Nicholas Paldino [.NET/C# MVP]"
Max,

The equivalent would be a static member on a type (preferably public,
so any other class can see it).

However, this isn't really that scalable, so you should be careful when
using it.

Feb 16 '06 #3
Hi,

"Max André Bündchen" <no****@microsoft.com> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
I'm reading the Pro C# 2005 and the .Net 2.0 Plataform by Andrew Troelsen
(in time, a nice book!) and a question is in my mind.

Supose that I have a WinForm application that has a login system. With the
login, I take from de DB many user informations that I would use in each
type (premisions for business class, screen options for forms...).

An approach in other OO-Languages is to make a global object "User" with
this informations.

What's the best approach in C# to accomplish this requiriments?

Assuming that you have a User class where you define all the user's
permission & details you can have a static property that return the logged
user:

class User
{
static User loggeruser;

public static LoggedUser { get{return loggeruser;} set{ loggeruser =
value;}}
}

you call it like:

User currentUser = User.LoggedUser;
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by David Hitillambeau | last post: by
6 posts views Thread by Christina N | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.