C#基本语法

using System;

namespace RectangleApplication {

   class Rectangle {
      // member variables
      double length;
      double width;

      public void Acceptdetails() {
         length = 4.5;    
         width = 3.5;
      }

      public double GetArea() {
         return length * width; 
      }

      public void Display() {
         Console.WriteLine("Length: {0}", length);
         Console.WriteLine("Width: {0}", width);
         Console.WriteLine("Area: {0}", GetArea());
      }
   }

   class ExecuteRectangle {

      static void Main(string[] args) {
         Rectangle r = new Rectangle();
         r.Acceptdetails();
         r.Display();
         Console.ReadLine(); 
      }
   }
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/265764.html

(0)
上一篇 2022年6月7日 21:06
下一篇 2022年6月7日 21:06

相关推荐

发表回复

登录后才能评论