美文网首页
c#基础语法

c#基础语法

作者: yz_wang | 来源:发表于2018-07-23 11:35 被阅读0次
    using System;  //在任何 C# 程序中的第一条语句都是
    namespace RectangleApplication
    {
        class Rectangle
        {
            // 成员变量
            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#基础语法

          本文链接:https://www.haomeiwen.com/subject/rkmajftx.html