I realise this is probably a very simple question and will be answered in no time. But wondering what to do. I have a class called Budget with an object named 'user01' I would basically like to be able to access that object across multiple classes, similar to the code below.
Main
static void Main(string[] args) { Budget user01 = new Budget(1000); } Budget Class
class Budget { private int _budget; public Budget(int budget) { _budget = budget; } public int UserBudget { get { return _budget; } set { _budget = value; } } } Expense Class
class Expenses { // What I've been trying to do... public int Something(user01.budget) { user01.budget - 100; return user01.budget; } } I'm not really sure where to go from here, and am hoping to a little help/explanation. Many thanks
mainhas to be in a class as well; you could make the object a public property of that class and then simply access it from other classes like so:MainClass.budget01.