public void DoSomeStuff(string myString1, string myString2) { if (MyVarClass == null) { MyVarClass = new MyVariableClass(); } MyVarClass.MyVariable = (!string.IsNullOrEmpty(myString2) ? myString2 : "String 2 has nothing!"); }
static void Main(string[] args) { MyMethods myMethod = new MyMethods(); MyVariableClass myVarClass = new MyVariableClass(); string something = "something"; string nothingHere = null; myMethod.DoSomeStuff(myVarClass, something, nothingHere); //I need to call MyVariable here //Or be able to access it's values assigned in the MyMethod Class. Console.Write(myVarClass.MyVariable); Console.ReadKey(); }
public void DoSomeStuff(MyVariableClass myVarClass, string myString1, string myString2) { myVarClass.MyVariable = (!string.IsNullOrEmpty(myString2) ? myString2 : "String 2 has nothing!"); }