code_junkie

interface good practices

Nov 13th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. public interface IHasAddress {
  2. public string Street1 { get; set; }
  3. public string Street2 { get; set; }
  4. public string City { get; set; }
  5. public string State { get; set; }
  6. public string Zip { get; set; }
  7. }
  8.  
  9. public static class Test {
  10. public static void CheckZip(IHasAddress addressContainer) {
  11. if (addressContainer == null) return;
  12. if (addressContainer.Zip == "33314") addressContainer.State = "FL";
  13. }
  14. }
  15.  
  16. User user = new User();
  17. Business business = new Business();
  18. Test.CheckZip(user);
  19. Test.CheckZip(business);
Add Comment
Please, Sign In to add comment