How do I get the same instance of an object across multiple classes?

Just saying the program probably makes no sense, but I am not doing this, this is just an example for the question.

Say I have object class "Lamp" and field "Brightness", and then go into the main class (Usually "Program" in VS by default I think) and create the object there and say…

Class Program{ Lamp redLamp = new Lamp(); redLamp.brightness = 20; } 

and then make a new class… Say class "Foo"… How can change or use "redLamp" I made in Class Program in Class Foo?

by Mat2012H via /r/csharp

Leave a Reply