I am working on a small application to get a grips with C# and i have written a small application that currently adds up values of items (currently predefined) Here is what i have so far:
//Defining classes
public class Item1{
public string Type{get{return "Item1";}}
}
public class Item2{
public string Type{get{return "Item2";}}
}
//Methods
public void CalcItems(Item1 item1, int val){
this.Log(item1.Type + "Val:" + val);
this.total += val;
}
public void CalcItems(Item2 item2, int val){
this.Log(item2.Type + "Val:" + val);
this.total += val;
}
//Calling these methods
Items.CalcItems(new Item1(), 30);
Items.CalcItems(new Item2(), 12);
How can I pass both Item1 and Item 2 through one calc method?