interface ISomeInterface { string Id{get; set;} void Display(); Dictionary<string, string> DataValues{get;}; TypedDataSet MetaData{get; } IList<Record> RecordCollection{get; } } public class A: ISomeInterface { public string Id { return "A1"; } void Display() { Console.Writeline("class A"); } public Dictionary<string, string> DataValues() { return new Dictionary<string, string>(); } public TypedDataSet MetaData() { //I dont want this method for class A throw new NotImplementedException(); } public IList<Record> RecordCollection() { //I dont want this method for class A throw new NotImplementedException(); } } public class B: ISomeInterface { public string Id { return "B1"; } void Display() { Console.Writeline("class B"); } public Dictionary<string, string> DataValues() { //I dont want this method for class B throw new NotImplementedException(); } public TypedDataSet MetaData() { return new TypedDataSet(); } public IList<Record> RecordCollection() { IList<Record> rc = null; //do something return rc; } }
Client App - Main() { ISomeInterface a = new A(); a.Display(); Dictionary<string, string> data = a.DataValues(); ISomeInterface b = new B(); b.Display(); TypedDataSet data = b.MetaData(); IList<Record> rc = b.RecordCollection(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)