472,811 Members | 1,410 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 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 1050
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions>...
3
by: Pavan | last post by:
Hi i would like to know abt the data variable storage in C like 1.where does global variables gets stored and why is it so .. 2.like wise static ,local variables, as for as i know i remember...
6
by: Christina N | last post by:
.... reward the one that can show me how to use an array to keep track of the active sessions (session-ids, logontimes, etc) in my ASP.Net application. Of course I can't reward anyone here, but...
44
by: petermichaux | last post by:
Hi, I have been using the following line of code to create an object called "Serious" if it doesn't already exist. if (Serious == null) {var Serious = {};} This works in the scripts I use...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{

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.