I'm trying to fully understand the interface concept so bare with me
let's say i created this interface:
and implement its properties and methods in this class:Code:public interface INameable { string FirstName { set; get; } string LastName { set; get; } string GetLastNameFirst(); }
now i want to implement this interface in another class but i don't want toCode:public class entity : INameable { public string FirstName { get; set; } public string LastName { get; set; } public string GetLastNameFirst() { return String.Format("{0} {1}", FirstName, LastName); } }
re-write "GetLastNameFirst" method since i already wrote it in the above class
(entity)
so how do i re-use that method in my new class:
Code:public class Worker : INameable { public string FirstName { get; set; } public string LastName { get; set; } // here i don't want to re-write the method, i just want to re-use the // method i wrote in the above entity class) public string GetLastNameFirst() { return "???"; } }
any pointers or direction will be appreciated!





If you Like it 
Reply With Quote