static void Main(string[] args) { Cavalry cav = new Cavalry { number = 1000, power = 50 }; cav.calcPower(); Console.WriteLine("Bu ordunun birlik türü: " + cav.type + " asker sayisi: " + cav.number + " Toplam Gücü: " + cav.allpow); var clonecav = cav.Clone(); //klonlama işlemi clonecav.number = 500; clonecav.calcPower(); Console.WriteLine("Bu ordunun birlik türü: " + clonecav.type + " asker sayisi: " + clonecav.number + " Toplam Gücü: " + clonecav.allpow); Infantry inf = new Infantry { number = 1000, power = 25 }; inf.calcPower(); Console.WriteLine("Bu ordunun birlik türü: " + inf.type + " asker sayisi: " + inf.number + " Toplam Gücü: " + inf.allpow); var cloneinf = inf.Clone(); //klonlama işlemi. cloneinf.number = 2000; cloneinf.calcPower(); Console.WriteLine("Bu ordunun birlik türü: " + cloneinf.type + " asker sayisi: " + cloneinf.number + " Toplam Gücü: " + cloneinf.allpow); }
public static void Main() { var stormCommander = new Commander(); var infantry = new Infantry(); var stormCommander2 = stormCommander.Clone() as Commander; var infantry2 = infantry.Clone() as Infantry; if (stormCommander2 != null) Console.WriteLine("Firepower: {0}, Armor: {1}", stormCommander2.FirePower, stormCommander2.Armor); if (infantry2 != null) Console.WriteLine("Firepower: {0}, Armor: {1}", infantry2.FirePower, infantry2.Armor); }
static void Main(string[] args) { Commander stormCommander = new Commander(); Infantry infantry = new Infantry(); Commander stormCommander2 = stormCommander.Clone() as Commander; Infantry infantry2 = infantry.Clone() as Infantry; if (stormCommander2 != null) { Console.WriteLine("Firepower: {0}, Armor: {1}", stormCommander2.FirePower, stormCommander2.Armor); } Console.ReadKey(); }
public static void Main() { var stormCommander = new Commander(); var infantry = new Infantry(); var stormCommander2 = stormCommander.Clone() as Commander; var infantry2 = infantry.Clone() as Infantry; if (stormCommander2 != null) { Console.WriteLine("Firepower: {0}, Armor: {1}", stormCommander2.FirePower, stormCommander2.Armor); } if (infantry2 != null) { Console.WriteLine("Firepower: {0}, Armor: {1}", infantry2.FirePower, infantry2.Armor); } }