CSharp examples for Custom Type:Field
Change private field via method
using System;//from w w w . j av a2 s . c o m class Train { private uint distance = 0; public void MoveBySteam(uint addDistance) { Console.WriteLine("Moving {0} kilometers by steam", addDistance); distance += addDistance; } public void MoveByElectricity(uint addDistance) { Console.WriteLine("Moving {0} kilometer by electricy", addDistance); distance += addDistance; } public void TestingDistance() { Console.WriteLine("Testing. distance instance variable: {0}", distance); } } class Tester { public static void Main() { Train orientExpress = new Train(); orientExpress.MoveBySteam(100); orientExpress.MoveByElectricity(200); orientExpress.TestingDistance(); } }