接口作为返回值
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace 接口作为返回值
7 {
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 Circle circle = new Circle(35);
13
14 MyClass myclass = new MyClass(circle);
15
16 Circle circle1 = (Circle)myclass.MyOutput(circle);
17 Console.WriteLine(circle1.Area);
18
19 Console.ReadLine();
20 }
21 }
22
23 interface IShape
24 {
25 int Area
26 {
27 get;
28 set;
29 }
30 void Caculate();
31 }
32
33 class Circle :IShape
34 {
35 int area = 0;
36 public Circle(int m_Area)
37 {
38 area = m_Area;
39 }
40 #region IShape成员
41 public int Area
42 {
43 get
44 {
45 return area;
46 }
47 set
48 {
49 area = value;
50 }
51 }
52 public void Caculate()
53 {
54 Console.WriteLine("计算面积!");
55 }
56 #endregion
57 }
58 class MyClass
59 {
60 public MyClass(IShape m_shape)
61 {
62 m_shape.Caculate();
63 Console.WriteLine(m_shape.Area);
64 }
65 /// <summary>
66 /// MyOutput方法
67 /// </summary>
68 /// <param name="m_shape">IShape 接口类型参数</param>
69 /// <returns>IShape 接口类型返回值</returns>
70 public IShape MyOutput(IShape m_shape)
71 {
72 m_shape.Area = 100;
73 return m_shape;
74 }
75 }
76
77
78 }
79