C# syntax is highly expressive, yet it is also simple and easy to learn. The curly-brace syntax of C# will be instantly recognizable to anyone familiar with C, C++ or Java. Developers who know any of these languages are typically able to begin to work productively in C# within a very short time. C# syntax simplifies many of the complexities of C++ and provides powerful features such as nullable value types, enumerations, delegates, lambda expressions and direct memory access, which are not found in Java. C# supports generic methods and types, which provide increased type safety and performance, and iterators, which enable implementers of collection classes to define custom iteration behaviors that are simple to use by client code. Language-Integrated Query (LINQ) expressions make the strongly-typed query a first-class language construct.
As an object-oriented language, C# supports the concepts of encapsulation, inheritance, and polymorphism. All variables and methods, including the Main method, the application's entry point, are encapsulated within class definitions. A class may inherit directly from one parent class, but it may implement any number of interfaces. Methods that override virtual methods in a parent class require the override keyword as a way to avoid accidental redefinition. In C#, a struct is like a lightweight class; it is a stack-allocated type that can implement interfaces but does not support inheritance.
In addition to these basic object-oriented principles, C# makes it easy to develop software components through several innovative language constructs, including the following:
C #ไวยากรณ์จะแสดงออกอย่างมาก แต่ก็ยังง่ายและสะดวกในการเรียนรู้ หยิกรั้งของไวยากรณ์ C #จะได้รู้จักกับใครที่คุ้นเคยกับ C , C หรือ Java นักพัฒนาที่รู้ใด ๆของภาษาเหล่านี้มักจะสามารถที่จะเริ่มงานงอกงามใน C #ภายในเวลาที่สั้นมากC #ไวยากรณ์ง่ายหลายซับซ้อนของ C และมีคุณลักษณะที่มีประสิทธิภาพเช่น nullable ค่าประเภท เครื่องตัวแทน นิพจน์แลมดาหน่วยความจำและการเข้าถึงโดยตรง ซึ่งจะไม่พบในชวา C #สนับสนุนวิธีการทั่วไปและประเภทที่ให้เพิ่มความปลอดภัยและประสิทธิภาพ iterators ชนิด , และ ,ซึ่งช่วยให้แต่เรียนคอลเลกชันที่กำหนดเองทำซ้ำพฤติกรรมที่ใช้ง่ายโดยรหัสลูกค้า ภาษาสอบถามเชิงบูรณาการ ( LINQ ) การแสดงออกให้ขอพิมพ์แบบสอบถามภาษาชั้นหนึ่งสร้าง .
เป็นภาษาเชิงวัตถุ , C #สนับสนุนแนวคิด encapsulation , มรดกและ polymorphism . ตัวแปรทั้งหมดและวิธีการ รวมถึงวิธีการหลักจุดเริ่มต้นของการห่อหุ้มอยู่ภายในห้องเรียนคำจำกัดความ ชั้นอาจจะสืบทอดโดยตรงจากผู้ปกครองชั้นเรียน แต่มันอาจจะใช้หมายเลขใด ๆของการเชื่อมต่อ . วิธีการแทนที่วิธีการเสมือนจริงในผู้ปกครองชั้นเรียนต้องแทนที่คำหลักเป็นวิธีการหลีกเลี่ยงการนิยามความหมายใหม่จากอุบัติเหตุ ใน C # , ซอฟต์แวร์ที่เป็นเหมือนชั้นเบา ;มันคือกองจัดสรรประเภทที่สามารถใช้อินเทอร์เฟซ แต่ไม่สนับสนุนการถ่ายทอด
นอกจากนี้พื้นฐานหลักการเชิงวัตถุ C #ทำให้ง่ายที่จะพัฒนาส่วนประกอบซอฟต์แวร์ผ่านหลายนวัตกรรมสร้างภาษา รวมถึงต่อไปนี้ :
การแปล กรุณารอสักครู่..
