一个 Rectangle(矩形)类的实现, C# 的基本语法:

 1 using System;
 2 
 3 namespace _12_23
 4 {
 5     class Program
 6     {
 7         int lengh = 5;
 8         int width = 9;
 9         public int Space()
10         {
11             return lengh * width;
12         }
13         public void Print()
14         {
15             Console.WriteLine("长{0}", lengh);
16             Console.WriteLine("宽{0}", width);
17             Console.WriteLine("面积{0}", Space());
18         }
19         static void Main(string[] args)
20         {
21             Program pro = new Program();
22             pro.Space();
23             pro.Print();
24             Console.ReadKey();
25         }
26     }
27 }

 

posted @ 2016-12-23 00:58  哈库拉灬玛塔塔  阅读(1161)  评论(0)    收藏  举报