Visual Studio:
Visual Studio 2022 is a powerful and comprehensive Integrated Development Environment (IDE)
created by Microsoft. Essentially, it's a software application that provides a wide range of tools and
features to help software developers write, test, and deploy computer programs.
إنها تطبيق برمجي، في األساسMicrosoft. هي بيئة تطوير متكاملة قوية وشاملة تم إنشاؤها بواسطةVisual Studio 2022
.يوفر مجموعة واسعة من األدوات والميزات لمساعدة مطوري البرامج على كتابة برامج الكمبيوتر واختبارها ونشرها
Here's a breakdown of what that means:
• Integrated Development Environment (IDE):بيئة التطوير المتكاملة
This means it brings together all the essential tools a developer needs into a single application.
.هذا يعني أنها تجمع كل األدوات األساسية التي يحتاجها المطور في تطبيق واحد
This includes:
1. A code editor for writing and editing code.محرر أكواد لكتابة وتحرير الكود
2. A debugger for finding and fixing errors.مصحح أخطاء للعثور على األخطاء وإصالحها
3. Compilers for translating code into executable programs.مترجمون لترجمة الكود إلى برامج قابلة للتنفيذ
4. Tools for managing projects and files.أدوات إلدارة المشاريع والملفات
• Key Features of Visual Studio 2022 الميزات الرئيسية لـ:
1. Multi-language support دعم متعدد اللغات:
It supports a wide variety of programming languages, including C#, C++, Python, JavaScript, and
many others.
2. Cross-platform development التطوير عبر األنظمة األساسية:
It enables developers to build applications for various platforms, including Windows, web, mobile,
and cloud.
3. Enhanced productivity سنة ّ إنتاجية مح:
It includes features like IntelliSense (code completion), code refactoring, and AI-powered assistance
to help developers write code more efficiently.
4. Debugging and testing tools أدوات التصحيح واالختبار:
It provides robust debugging tools to help developers identify and fix errors, as well as testing tools
to ensure code quality.
5. Cloud integration التكامل السحابي:
It integrates with Microsoft Azure, making it easy to build and deploy cloud-based applications.
6. Version control التحكم في اإلصدار:
It has integrated Git support, facilitating collaboration and code management.
7. Editions اإلصدارات:
▪ Visual Studio 2022 is available in different editions, including:
: بما في ذلك، في إصدارات مختلفةVisual Studio 2022 يتوفر
✓ Community المجتمع: A free edition for students, open-source contributors, and individual
developers.
✓ Professional المحترف: A paid edition for professional developers and small teams.
✓ Enterprise المؤسسات: A paid edition for large teams and enterprise-level development.
In summary, Visual Studio 2022 is a feature-rich IDE that empowers developers to build a wide
range of software applications.
DR\Muaadh Abdo Al Sabri
C#
C# is a versatile and powerful programming language widely used for various
software development tasks.
. هي لغة برمجة متعددة االستخدامات وقوية تستخدم على نطاق واسع في مهام تطوير البرامج المختلفة#C
Here's a breakdown of key aspects:
▪ Key Characteristics الخصائص الرئيسية:
1. General-purpose األغراض العامة:
C# can be used to create a wide range of applications, from desktop software to web
applications and mobile apps.
من برامج سطح المكتب إلى تطبيقات الويب وتطبيقات، إلنشاء مجموعة واسعة من التطبيقات#C يمكن استخدام
.الهاتف المحمول
2. Object-oriented :
It follows the object-oriented programming (OOP) paradigm, which emphasizes
organizing code into reusable components called objects. This promotes code clarity
and maintainability.
والذي يؤكد على تنظيم التعليمات البرمجية إلى مكونات قابلة،)OOP( تتبع نموذج البرمجة الموجهة للكائنات
. وهذا يعزز وضوح التعليمات البرمجية وقابليتها للصيانة.إلعادة االستخدام تسمى الكائنات
3. Modern and Evolving :
C# is actively developed by Microsoft, with regular updates that introduce new
features and improvements.
مع تحديثات منتظمة تقدم ميزات وتحسينات،Microsoft بنشاط بواسطة#C يتم تطوير:حديثة ومتطورة
.جديدة
4. .NET Platform:
DR\Muaadh Abdo Al Sabri
C# is tightly integrated with the .NET platform, a framework that provides a
comprehensive set of tools and libraries for building applications.
.NET:منصة
وهو إطار عمل يوفر مجموعة شاملة من األدوات والمكتبات لبناء، .NETمتكاملة بشكل وثيق مع منصةC#
.التطبيقات
5. Cross-platform capabilities:
Through the .NET platform, C# can be used to develop applications that run on various
operating systems.
:إمكانات متعددة المنصات
. لتطوير التطبيقات التي تعمل على أنظمة تشغيل مختلفة#C يمكن استخدام،NET. من خالل منصة
▪ Common Uses االستخدامات الشائعة:
a. Windows desktop applications:
C# is a popular choice for building traditional Windows software.
b. Web development:
With [Link], C# is used to create dynamic and scalable web applications.
c. Game development:
C# is widely used in game development, particularly with the Unity game engine.
d. Mobile app development:
C# can also be used to create mobile applications.
e. Cloud-based services:
C# is heavily used in building cloud applications, especially with Microsoft Azure.
▪ Key Advantages:
1) Strong typing:
C# enforces strong typing, which helps prevent errors and improves code reliability.
Large community:
C# has a large and active community, providing ample resources and support for
developers.
2) Rich libraries:
The .NET platform offers a vast library of pre-built components, simplifying
development.
In essence, C# is a robust and flexible language that empowers developers to build a
wide spectrum of software solutions.
Main Components of C#
When discussing the main components of C#, it's important to differentiate between
the language itself and the environment it operates within (.NET). Here's a breakdown:
• Core C# Language Components:
DR\Muaadh Abdo Al Sabri
1. Namespaces:
These organize code into logical groups, preventing naming conflicts and improving
code readability.
2. Classes:
The fundamental building blocks of object-oriented programming in C#. They
encapsulate data (fields) and behavior (methods).
3. Methods:
These define the actions that a class can perform. The Main method is the entry point
for a C# program.
4. Variables:
Used to store data. C# is a strongly typed language, so variables must have a specific
data type (e.g., integer, string).
5. Data Types:
C# has a rich set of built-in data types, including:
Value types (e.g., int, float, bool, struct)
Reference types (e.g., string, class, array)
6. Statements and Expressions:
Statements are instructions that the program executes, while expressions are code
snippets that evaluate to a value.
7. Control Structures:
These control the flow of execution, including:
Conditional statements (e.g., if, else, switch)
Loops (e.g., for, while, foreach)
8. Attributes:
These provide metadata that can be added to code elements.
• Components within the .NET Environment:
➢ Common Language Runtime (CLR):
The execution engine of .NET. It manages memory, handles exceptions, and provides
other runtime services.
✓ .NET Class Library (FCL):
A vast collection of pre-written code that provides functionality for various tasks, such
as file I/O, networking, and data access.
✓ Compiler:
The compiler takes the C# code and translates it to Common Intermediate Language
(CIL). Then the CLR's JIT compiler translates the CIL into native machine code.
In essence, C# provides the language features, while the .NET environment provides
the runtime and libraries necessary to execute C# code.
DR\Muaadh Abdo Al Sabri
➢ Common Type System (CTS)
The CTS is a standard that defines how data types are declared, used, and managed
within the .NET environment.
Essentially, it provides a unified type system that all .NET languages must adhere to.
This ensures that different languages can work together seamlessly.
.NET. هو معيار يحدد كيفية إعالن أنواع البيانات واستخدامها وإدارتها داخل بيئةCTS
وهذا يضمن أن اللغات المختلفة.NET. يوفر نظا ًما موحدًا لألنواع يجب أن تلتزم به جميع لغات،في األساس
.يمكنها العمل م ًعا بسالسة
➢ Common Language Specification
The CLS is a set of rules that define a subset of the CTS.
It specifies the minimum requirements that a language must meet to interoperate
seamlessly with other .NET languages.
In essence, it's a set of guidelines that language compilers should follow to produce
code that can be used by other .NET languages.
.CTS عبارة عن مجموعة من القواعد التي تحدد مجموعة فرعية منCLS
. األخرىNET. تحدد المتطلبات الدنيا التي يجب أن تلبيها لغة ما للتفاعل بسالسة مع لغات
جمعو اللغات إلنتاج كود يمكن استخدامه بواسطة
ِّ إنها مجموعة من اإلرشادات التي يجب أن يتبعها ُم،في األساس
. األخرىNET. لغات
. جميع أنواع البيانات الممكنةCTS يحدد
. لتكون قادرة على العمل مع بعضها البعض، أنواع البيانات التي يجب أن تتقاسمها جميع اللغاتCLS يحدد
Variables in C#
In C#, variables are fundamental building blocks that act as containers for storing data
during a program's execution.
. تعد المتغيرات بمثابة وحدات بناء أساسية تعمل كحاويات لتخزين البيانات أثناء تنفيذ البرنامج،# C في لغة
Here's a detailed explanation:
❖ Core Concepts المفاهيم األساسية:
✓ Storage Locations مواقع التخزين
Variables represent specific locations in the computer's memory where data can be
held.
.تمثل المتغيرات مواقع محددة في ذاكرة الكمبيوتر حيث يمكن تخزين البيانات
✓ Data Types أنواع البيانات
C# is a strongly typed language, meaning every variable must have a defined data
type. This type dictates the kind of data the variable can store (e.g., numbers, text,
true/false values).
يحدد هذا النوع نوع. مما يعني أن كل متغير يجب أن يكون له نوع بيانات محدد، هي لغة ذات نوع قوي#C لغة
.)الخاطئة/ األرقام والنصوص والقيم الصحيحة،البيانات التي يمكن للمتغير تخزينها (على سبيل المثال
✓ Naming التسمية
DR\Muaadh Abdo Al Sabri
Each variable is assigned a unique name (identifier) that allows you to access and
manipulate its stored data.
(مالحظة قواعد.يتم تعيين اسم فريد (معرف) لكل متغير يسمح لك بالوصول إلى بياناته المخزنة ومعالجتها
)تسمية المتغيرات
✓ Initialization التهيئة:
Variables can be initialized (given an initial value) when they are declared, or they
can be assigned values later during program execution.
. أو يمكن تعيين قيم لها الحقًا أثناء تنفيذ البرنامج،يمكن تهيئة المتغيرات (بإعطائها قيمة أولية) عند إعالنها
❖ Key Characteristics الخصائص الرئيسية:
• Type Safety سالمة النوع:
C#'s strong typing ensures that only compatible data can be stored in a variable,
preventing many common programming errors.
مما يمنع العديد من أخطاء البرمجة، تخزين البيانات المتوافقة فقط في متغير#C تضمن الكتابة القوية في لغة
.الشائعة
• Scope النطاق:
The scope of a variable defines where in the code it can be accessed. Variables can
have a local scope (within a specific block of code) or a broader scope (e.g., within a
class).
يمكن أن يكون للمتغيرات نطاق محلي (داخل كتلة معينة من.يحدد نطاق المتغير مكان الوصول إليه في الكود
.) داخل فئة،الكود) أو نطاق أوسع (على سبيل المثال
• Lifetime العمر االفتراضي:
A variable's lifetime determines how long it exists in memory. Local variables
typically exist only while the block of code they are defined in is executing. Class-
level variables exist for the lifetime of the class instance.
توجد المتغيرات المحلية عادة ً فقط أثناء تنفيذ كتلة.يحدد عمر المتغير المدة التي يظل فيها موجودًا في الذاكرة
. توجد المتغيرات على مستوى الفئة طوال عمر مثيل الفئة.الكود التي تم تعريفها فيها
❖ Types of Variables أنواع المتغيرات:
➢ C# defines several categories of variables :
عدة فئات من المتغيراتC# يحدد
a. Local Variables المتغيرات المحلية:
Declared within a method, block, or other local scope.
.يتم إعالنها داخل طريقة أو كتلة أو نطاق محلي آخر
b. Instance Variables (Fields) متغيرات المثيل
Declared within a class but outside of any method. Each instance of the class has its
copy of instance variables.
DR\Muaadh Abdo Al Sabri
. كل مثيل للفئة لديه نسخة من متغيرات المثيل.يتم إعالنها داخل فئة ولكن خارج أي طريقة
c. Static Variables (Static Fields) المتغيرات الثابتة:
Declared with the static keyword. They belong to the class itself, not to any specific
instance.
. وليس إلى أي مثيل محدد، وهي تنتمي إلى الفئة نفسهاstatic. يتم إعالنها باستخدام الكلمة األساسية
d. Array Elements عناصر المصفوفة:
Variables that hold values within an array.
المتغيرات التي تحتوي على قيم داخل مصفوفة
e. Parameters المعلمات:
Variables that receive values passed to methods.
.المتغيرات التي تتلقى القيم التي يتم تمريرها إلى الدوال
❖ Data Types in C:#
. مجموعة غنية من أنواع البيانات المضمنة#C توفر: #C أنواع البيانات في
C# provides a rich set of built-in data types:
1. Value Types:
Store the actual data value directly in memory.
Examples: int, float, double, bool, char, struct.
:تعيد قيمة
.تخزن قيمة البيانات الفعلية مباشرة في الذاكرة
.struct ،char ،bool ،double ،float ،int :األمثلة
2. Reference Types:
Store a reference (memory address) to the data.
Examples: string, class, array, delegate.
:تعيد مرجع
.تخزن مرجعًا (عنوان ذاكرة) للبيانات
delegate. ،array ،class ،: stringاألمثلة
DR\Muaadh Abdo Al Sabri
إلنشاء مشروع جديد يجب ان يتم الوصول الى الواجهة التالية:
▪ من قائمة ابداء يتم فتح بيئة الدوت نت Visual Studio 2022كالتالي:
DR\Muaadh Abdo Al Sabri
يتم اختيار Create a new projectالنشاء مشروع جديد حيث سوف تظهر لك نافذة تحوي على العديد من
المشاريع التي سوف ندرس اهمها:
Windows Forms Application .1
وهي البرامج ذات النوافذ كال نوافذ الويندوز ويكون إمتدادهاexe
Class Library .2
وهي عبارة عن صنف برمجي فارغ للبدأ ببرمجته من الصفر ويكون إمتدادهdll
[Link] Web Application .3
إنشاء تطبيقات Webباستخدام تقنية[Link]
[Link] Web Service Application .4
إنشاء خدمات لتطبيقات الويب باستخدام تقنية[Link]
WPF Application .5
وهي برامج متطورة يستخدم في رسمها لغةxml
Console Application .6
وهي تطبيق مهمته تنفيذ شيء ثم اإلغالق وسوف تظهر ال Consoleأثناء تنفيذ هذا البرنامج
وعادة ما يستخدم في برامج فك الضغط .النسخ,,,
Windows Forms Control Library .7
لتصنيع أداة خاصة بك الستخدامها في تطبيقاتWindows Form Application
DR\Muaadh Abdo Al Sabri
واالن نعود إلى موضوعنا سوف نختارWindows Forms Application
بعد تسمية المشروع project Nameوالنقر على زر Nextستظهر لنا الواجهة التالية :
DR\Muaadh Abdo Al Sabri
في مرحلة سابقة تعرفنا على بعض النقاط في واجهة ، Visual Studioاآلن سنواصل التعرف على النقاط الخاصة بالواجهة
الرسومية.:
ToolBox -1
يحتوي على األدوات الرئيسية التي نحتاج اليها ،لو لم يكن ظاهر ا يمكننا اظهاره من- View ToolBox .
شريط الخصائص تجد فيها الخصائص التي ترغب في تعديلها ألي عنصر يتم تحديده
على الفورم ،هذه الصورة توضح خصائص احد عناصر القائمة.
DR\Muaadh Abdo Al Sabri