Docly

c# Basic Syntax and Keywords

Estimated reading: 3 minutes 271 views

C# هي لغة برمجة متعددة الأغراض تستخدم لتطوير تطبيقات سطح المكتب وتطبيقات الويب وتطبيقات الموبايل وتطبيقات ألعاب الفيديو. وتتميز C# بوجود قواعد صارمة في البناء اللغوي والتحكم في النمط الذي يتم البرمجة به.

يتكون بناء C# من مجموعة من العناصر الأساسية، والتي تشمل الإجراءات (Methods) والفئات (Classes) والكائنات (Objects) والمتغيرات (Variables). ويتم استخدام الإجراءات لتنفيذ العمليات اللازمة في البرنامج، بينما يتم استخدام الفئات لتجميع الإجراءات والمتغيرات ذات الصلة. ويتم استخدام الكائنات لتمثيل الفئات بشكل فعال، ويتم استخدام المتغيرات لتخزين البيانات التي يتم استخدامها في البرنامج.

بناء البرنامج

وتتكون بناء البرنامج في C# من تعليمات البرمجة التي يتم إدخالها في محرر النصوص، ويتم ترجمتها إلى رمز آلي يمكن تنفيذه من قبل الحاسوب. وتتكون التعليمات البرمجية في C# من الكلمات الرئيسية والمعاملات والتعليقات والأوامر.

وتشمل الكلمات الرئيسية في C# الكلمات المحجوزة التي تستخدم للإشارة إلى أنواع البيانات والإجراءات والفئات والمتغيرات المختلفة المستخدمة في البرنامج. وتشمل المعاملات البيانات التي يتم استخدامها في البرنامج، بما في ذلك الأعداد والنصوص والبيانات المنطقية. وتستخدم التعليقات لإضافة ملاحظات إضافية في الرمز البرمجي، ويتم تجاهلها من قبل الحاسوب عند تنفيذ البرنامج. وتتضمن الأوامر مجموعة

c# Keywords

 

C# is a programming language that makes use of a wide range of keywords to enable developers to create powerful applications. These keywords provide specific functionality that helps to make coding in C# more efficient and effective. Some of the most commonly used C# keywords include 'if', 'else', 'while', 'for', 'switch', 'case', 'break', 'continue', 'return', 'class', 'struct', 'interface', 'enum', 'abstract', 'sealed', 'static', 'const', and 'using'. Each of these keywords has a specific role to play in the C# language, enabling developers to write code that is concise, easy to read, and easy to understand.
The 'if' keyword is used to test a specific condition and execute a block of code if the condition is true. The 'else' keyword is used in conjunction with 'if' to execute a different block of code if the condition is false. The 'while' keyword is used to repeatedly execute a block of code while a specified condition is true, and the 'for' keyword is used to iterate over a set of values for a fixed number of times.
The 'switch' keyword is used to test a value against a set of case values, executing a specific block of code for each case. The 'case' keyword is used to specify the value to test against, and the 'break' keyword is used to exit the switch statement. The 'continue' keyword is used to skip to the next iteration of a loop, while the 'return' keyword is used to return a value from a method or function.
The 'class' keyword is used to define a class, which is a blueprint for creating objects, while the 'struct' keyword is used to define a structure, which is a collection of related data types. The 'interface' keyword is used to define an interface, which is a collection of abstract methods that can be implemented by any class. The 'enum' keyword is used to define an enumeration, which is a set of named constants. The 'abstract' keyword is used to define an abstract class, which cannot be instantiated and must be inherited from, while the 'sealed' keyword is used to prevent a class from being inherited from.
The 'static' keyword is used to define a static member, which is a member that belongs to the class rather than to an instance of the class. The 'const' keyword is used to define a constant, which is a value that cannot be changed once it has been defined. Finally, the 'using' keyword is used to import a namespace, which is a collection of related classes, structures, and interfaces, into a C# program.
Share this Doc
CONTENTS