C# basic syntax


  Translation results:

C# is a modern, general-purpose, object-oriented programming language developed by Microsoft and approved by Ecma and ISO.

C# was developed by Anders Hejlsberg and his team during the development of the .Net framework.

C# is designed for the Common Language Infrastructure (CLI). The CLI consists of executable code and a runtime environment that allows the use of a variety of high-level languages ​​on different computer platforms and architectures.

C# basic syntaxsyntax

C# is an object-oriented programming language. In the object-oriented programming method, a program consists of various objects that interact with each other. Objects of the same kind usually have the same type, or are in the same class.

C# basic syntaxexample

using System;
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();
        }
    }}

Home

Videos

Q&A