C#封装private访问修饰符

using System;

namespace RectangleApplication {

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

      public void Acceptdetails() {
         Console.WriteLine(Enter Length: );
         length = Convert.Todouble(Console.ReadLine());
         Console.WriteLine(Enter Width: );
         width = Convert.Todouble(Console.ReadLine());
      }

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

      public void display() {
         Console.WriteLine(Length: {0}, length);
         Console.WriteLine(Width: {0}, width);
         Console.WriteLine(Area: {0}, GetArea());
      }
   }//end class Rectangle

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

相关文章

c#如何实现添加到列表代码:var list = new&...
c#循环访问字典代码:foreach(var item in m...
using System; namespace OperatorsAppl { class Program ...
using System; class Program { static void Main(string[...
using System; namespace OperatorsAppl { class Program {...
using System; namespace DeclaringConstants { class Pro...