473,378 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 1063
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.