Program.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 ConsoleInterface2
  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. interface Infornation2
  28. {
  29. string Code { get; set; }
  30. string Name { get; set; }
  31. void ShowInfo();
  32. }
  33. public class JHinfe : Infornation,Infornation2
  34. {
  35. string code = "";
  36. string name = "";
  37. string Infornation.Code
  38. {
  39. get { return code; }
  40. set { code = value; }
  41. }
  42. string Infornation.Name
  43. {
  44. get { return name; }
  45. set { name = value; }
  46. }
  47. string Infornation2.Code
  48. {
  49. get { return code; }
  50. set { code = value; }
  51. }
  52. string Infornation2.Name
  53. {
  54. get { return name; }
  55. set { name = value; }
  56. }
  57. void Infornation.ShowInfo()
  58. {
  59. Console.WriteLine("进货信息:" + code + " " + name);
  60. }
  61. void Infornation2.ShowInfo()
  62. {
  63. Console.WriteLine("进货信息:" + code + " " + name);
  64. }
  65. //在派生类中,除了实现接口中的成员外,还可以编写其它的成员(方法、属性等)
  66. public int Show()
  67. {
  68. return 0;
  69. }
  70. }
  71. }