Program.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Runtime.ConstrainedExecution;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace ConsoleInterface
  9. {
  10. internal class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Infornation info = new JHinfe();
  15. info.Name = "手机";
  16. info.Code = "001";
  17. info.ShowInfo();
  18. Console.ReadLine();
  19. }
  20. }
  21. interface Infornation
  22. {
  23. string Code { get;set; }
  24. string Name { get;set; }
  25. void ShowInfo();
  26. }
  27. public class JHinfe : Infornation
  28. {
  29. string code = "";
  30. string name = "";
  31. public string Code
  32. {
  33. get { return code; }
  34. set { code = value; }
  35. }
  36. public string Name
  37. {
  38. get { return name;}
  39. set { name = value; }
  40. }
  41. public void ShowInfo()
  42. {
  43. Console.WriteLine("进货信息:" + code + " " + name);
  44. }
  45. //在派生类中,除了实现接口中的成员外,还可以编写其它的成员(方法、属性等)
  46. public int Show()
  47. {
  48. return 0;
  49. }
  50. }
  51. }