C#基本语法

using System;namespace RectangleApplication {class Rectangle {// member variablesdouble length;double width;

编程学习网为您整理以下代码实例,主要实现: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(); 
      }
   }
}

本文标题为:C#基本语法

上一篇: C#类型转换
下一篇: C#常数和文字

基础教程推荐