static void Main(string[] args) { var r = new Random(); // A new class item IDataItem item = new DataItem { A = r.NextDouble(), B = r.NextDouble(), C = r.NextDouble(), D = r.NextDouble() }; // Type hinting here helps with inference // The resulting `newItem` is an "immutable" copy of the source item IDataItem newItem = item.With((DataItem x) => { x.A = 0; x.C = 2; }); // This won't even compile because Bonkers doesn't implement IDataItem! // No more casting madness and runtime errors! IBonkers newItem2 = item.With((Bonkers x) => { /* ... */ }); }
public bool Equals(IBonkers other) { throw new NotImplementedException(); }
public int CompareTo(IBonkers other) { throw new NotImplementedException(); }