0

I have question, how to create object/variables, and using it in another places in application?

I have class "User" with variables e.g. Name, Surname, privilege and method getPrivilage. After login I'm creating new User - loggedUser - but.. how in another form check privilage my "loggedUser"?

2

1 Answer 1

0

The best thing will be you can inherit the User class in your loggedUser class thus which gives you the Privilege property too.

CODE

 //Inheriting the User class as the LoggerUser will also be the type of User.    
 LoggedUser : User
 {
    //Logged User Functionality or In Constructor you can set the privilage property.
 }

var loggedUserObj = new LoggedUser(); 
var loggedUsePrivilage = loggedUserObj.privilage;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.