57

books.moswrat.com · Web viewنبذة مختصرة عن البرمجة: البرنامج: هو عبارة عن تطبيق سوفت وير تم أنشاؤه لأجراء عملية

Embed Size (px)

Citation preview

: البرمجة عن مختصرة نبذة:البرنامج

معين هدف تحقيق أو معينة عملية ألجراء أنشاؤه تم وير سوفت تطبيق عن عبارة هوبرامج مجموعة Office (Word,Excel,PowerPoint,…....,…...,.....)مثل

نص كتابة أو معينه أوراق طباعة مثل المكتبية األعمال بعض وتنفيذ إلنشاء تستخدم.. الخ مشابه أو ما لغرض

بسيط : مثالأو أكلتك يعملك البيت في حد فيش وما بيتك على ورايح شغلك من راجع انك تخيل

ماتريده كل ووجدت معينة أكلة إحضار في فكرت ثم المطبخ إلى أنت وذهبت الغداءاألكلة . تلك إلحضار خضروات أو أدوات من

األكلة هذه تعد كيف تفكر فأن دورك أصبح واآلنكل اآلن وأنت األكلة تحضر ازاى تعليمات فيه كتاب قدامك انك تخيل شديدة ببساطه

. تنفذ ثم تقرأ انك هو معليك.................. البرنامج هو أحضرتها التي األكلة

بطريقة معينه مشكلة بحل يقوم والبرنامج جوعك تشبع إن األكلة من الغرضمتطورة.

.............. المبرمج هو األكلة بإحضار قام الذيأكلتك تحضر إن استطعت والخضروات األدوات استخدام طريق عن

مثل..................................... معينه وبرامج كمبيوتر جهاز Visual Studioاألدوات

.........................................................................................................................

Visual Studio.NETبيئة

Console Applicationأوال: A project for creating a command-line application

OR the console window is the MS-DOS prompt.

لي DOSكلمة Disk Operating Systemاختصار

أوامر إلنشاء يستخدم انه السوداء DOSبمعنى الشاشة خالل من للتعامل أوباستخدام بسيط برنامج بعمل تقوم Consoleكيف

: التالية الخطوات تتبع

ذلك بعد ثم

1

األرقام تسلسل حسب هامشي هاتظهر اللي الشاشة من كده وبعد

الكود بكتابة فيها ستقوم التي النهائية البرنامج نافذة تظهر واآلن

2

المشاريع (3) أنواعالتي

هنا أنشاؤها يمكنc#

أسم (6) المشروع

ال( 5 ) تطبيقاتConsole

4))

اختار windows

الذي المكانحفظ فيه يتمالمشروع

باستخدام بسيطة أكواد كتابة كيفية على سنتعرف Consoleاآلن

الطباعة ) (Write Statementجملة

للمستخدم معينة معلومات إلظهار أو السوداء الشاشة على للطباعة تستخدمشكلها:

Console.WriteLine;)(

التالى السطر الى المؤشر ينتقل ثم الطباعة أمر تنفذ

او

Console.Write;)(

السطر نفس على واقف المؤشر يظل ولكن الطباعة أمر تنفذ

مثال:

Console.WriteLine)"welcome"(;

مكان الكود

كل عل يحتوىملفات المشروع

: التنفيذ ناتج

ولكن

Console.Write)"welcome"(;

: التنفيذ ناتج

ملحوظات:

( بعالمة ينتهي الزم الكود في سطر إي ( ;semicolonالحظ كلمة أيضا عن Consoleالحظ عبارة باألزرق classده ومكتوب

او ) محجوزة كلمة ماينفعش( reserved wardألنها يعنىكمتغير انت تستخدمه

كلمة كابيتل( w,lحرفى)WriteLine أيضًا او حروف طباعة حالة عالمتى stringفى بين الجملة توضع

( ارقام " " لو غير( " "2125الجملة من

:مثال

أسمك؟ لطباعة الطباعة جملة استخدم

Console.WriteLine)" sayed hussein elsayed"(;

على ) الضغط خالل من للبرنامج تنفيذ عمل ترى (ctrl+f5عندالشاشة هذه

: ارقام طباعة لو حالة فى

مثال:

Console.WriteLine)0141659968(;

التنفيذ ناتج

القراءة ) (Read Statementجملة

Console.ReadLine;)(

السوداء الشاشة خالل من المستخدم من قيم ألخذ تستخدم

:مثال

باستخدام برنامج يدخل consoleأنشئ أن المستخدم من يطلبهو ... أدخلته الذي االسم بطباعة البرنامج يقوم ثم اسمه

البرنامج:

Console.WriteLine)"please enter your name ..."(;string name =Console.ReadLine)(;

Console.WriteLine)"your name is"(;Console.WriteLine) name(;

ويقوم اسمك ادخل فضلك من الشاشة على يطبع التنفيذ عندالنوع من االسم ان وبما اسمه بكتابة قمنا stringالمستخدم

اسمه متغير بأدخاله nameبتعريف المستخدم مايقوم يستقبل

: هو التنفيذ ناتج

ملحوظة:

فقط نصية مدخالت إال المستخدم من تستقبل ال القراءة جملةالحل ما المستخدم من رقميه قيم استقبال أردنا أذا ولكن

المتغيرات أنواع بين التحويل يتم الكود هذا باستخدام

int num;num = Convert.ToInt32)Console.ReadLine)((;

القراءة ) (class: convert from data type to anotherجملة

مثال:

Console.WriteLine)" enter your number"(;int num;

num = Convert.ToInt32)Console.ReadLine)((;Console.Write)"the num you are enter is "(;

Console.WriteLine)num);التنفيذ :ناتج

النوع من متغير من أكثر تعريف اى int or floatعند أوالشاشة على األرقام تلك طباعة ونريد باألرقام خاص نوع

مثال:

النوع من متغيرين الرقم intعرف الشاشة على بطباعة قم ثمهو .... ..... الثاني والرقم هو األول

int frstnum = 20; int secnum = 30;Console.WriteLine)" the first num is {0} and the second

num is {1}",frstnum,secnum (;متغير أول إلى لإلشارة

متغير ثاني إلى لإلشارة

) التعريف ) إثناء المتغيرات ترتيب حسب على ذلك ويكون

: التنفيذ ناتج

Operators

ألداء أو لمتغير معينه قيمة إعطاء أو قيمتين بين مقارنة لعمل جملة كتابة عندحدوثه تريد الذي الفعل توضح التي الرموز بعض تستعمل فأنك حسابية عملية

. الجملة فيلغة داخل المستخدمة الرموز تلك أهم هي# .Cمن

جمل دراسة عند الرموز تلك استخدام وسيظهرIF,For,While,Do while

Types of errors:

Syntax error:غير قيمة متغير إعطاء أو الكود كتابة في أخطاء في لو يظهر خطأ عن عبارة هو

احمر )( خط تحته الخطأ بتالقي تضع تنسى انك أو صحيحة

Example:

int x = "sayed";

orConsole.WriteLine()

Logical error:

نتيجة ولكن البرنامج تنفيذ نتيجة أثناء أخطاء يوجد ال اى متوقع غير خطأ عن عبارة هوجمع ناتج عاوز مثال أنا هنا متوقعة غير أو المطلوبة النتيجة بتكونش ما البرنامج

Example:

int x = 5; int y = 10;int sum=x+y;Console.WriteLine(sum-y);

Exception error(runtime error):

أو صفر على حاجه بقسم لما مثال يهنج البرنامج يخلى كبير خطأ بيبقا دهمتغير قيمة بتغيير lower caseإلى nullأقوم

Example:string s = null;s.ToLower();

كله البرنامج معين خطأ وجود عشان ينفعش ما كنير اكواد بيه مشروع أو برنامج وجود حالة فياسمها حاجه اخترعوا كده وعشان معينة Exception handlingيقف طريقة عن عبارة فدى

به الخطأ بوجود البرمج يشك الذي المكان في توضع

الكود استخدام طريق try and catchعن

بين الكود وضع يتم

Syntax:

Try

{code}

Catch(exception any_char)

{

Cosole.writeline(any_char);

}

Example:

try{string s = null;s.ToLower();}catch(Exception ex) الخطأ رسالة فيه يستقبل متغير عن عبارة{Console.WriteLine(ex);}

:مالحظات

نوع يوجد ولكن البرنامج إثناء متغير اى قيمة تغير يمكنالبرنامج . إثناء ثابتة قيمته تظل المتغيرات من

كلمة نضع النوع ذلك من متغير أمام constلتعريف

المتغير

مثال:

const double r = 3.14;Console.WriteLine)r(;

بمعدل ما متغير قيمة طريقتين 1لزيادة هناك مرة كل فىP++ and ++p

بينهما فرق يوجد ولكن(: ++(pأوال

طباعة p = 4لو مرة++ pوعند أول ذلك 4يطبع بعد ثموهكذا 6ثم 5

(pثانيًا:)++طباعة ++p = 4لو مرة pوعند أول ذلك 5يطبع بعد 6ثموهكذا 7ثم

على: ++pمثال

int p = 4;Console.WriteLine)p++(;Console.WriteLine)p++(;Console.WriteLine)p++(;

: التنفيذ ناتج

على: ++ pمثال

int p = 4;Console.WriteLine)++p(;Console.WriteLine)++p(;Console.WriteLine)++p(;

: التنفيذ ناتج

المختلفة الحسابية العمليات تنفيذ :أولويةاليمين إلى اليسار من التنفيذ

األقواس إلى بالنسبة الخارج إلى الداخل منالطرح أو الجمع ثم القسمة ثم الضرب

مثال:

x=)3*)6+9((+)5+)20-5((;

+

عليها يسير التى هى المرقمه الخطوات ) الى البرمجة لغة من الجهاز المترجم لغة (compiler

( االولى العملية الثانية )15(=6+9ناتج الخطوة ذلك بعد ثم3*15 =)45

( الثالثة العملية )15(=20-5ناتج الرابعة العملية +15ناتج5 =)20

( الخامسة 65(=45+15الخطوة:التنفيذ

13

2 4

5

y=)6-)3+10/2((-)7*)9+4*4((;تجد الرياضى التسلسل طريقة بأتباع

177الناتج =-

: المتغيرات بين التحويل1-Implicit Conversion2-Explicit Conversion

Implicit Conversion

بسبب معلومات اى فقد عدم ضمان عند المختلفة األنواع بين أوتوماتيكيا التحويل يتمالتحويل

صغيره قيمة وضع اى األكبر النوع إلى األصغر النوع من التحويل عند يحصل دائما وهوكبير مخزن داخل

مثل :وهوInt x =123456 ; // int is 4 byte integerLong y = x; // implicit conversion to long( اى فقد يتم ال

ألن ( معلومات

Explicit Conversionأخبار التحويل compilerيتم بعملية

Int x =472 ;Short z = (short) x ; //explicit conversion to shortقيمة بوضع يقوم ألنه وذلك المعلومات بعض فقد يتم التحويل من النوع هذا في

. صغير مخزن داخل كبيرةإل المتغير compilerيقوم قيمة النوع xبتحويل النوع intمن shortإلى

المتغير في وضعه .zثممثال :

int x = 12345;long y; y = x; // implicity conversion short z; int w=10; z=)short(w; // explicity conversion

التحويل / / عند معلومات فقد يتم كيف نرى هناالنوع explicity من

double c = 3.5; int t;

t = )int(c; Console.WriteLine)t(; // 5ويفقد .3يطبع

: التنفيذ ناتج

if statementالبرنامج مسار في تتحكم التي الشرطية الجمل جملة If من تعتبر

If- statementIf else- statementIf- else if- statement

(If statement)Syntax:If (Boolean-expression){Statements}

Example:if )x > 50(

{Console.WriteLine)" value of x is greater than 50"(;

}

قيمة < أدخال شئ 50عند يفعل لم ذلك غير الرسالة يطبع

(If- else statement)Example:if )x > 50({Console.WriteLine)" value of x is greater than 50"(;

}else{Console.WriteLine)"value of x is less than 50"(;

}

قيمة < أدخال هايطبع 50عند كده غير االولى الرسالة يطبع الثانية الرسالة

(If- else if statement)

if )x > 50(

{Console.WriteLine)" value of x is greater than 50"(;

}else if)x>50({Console.WriteLine)"value of x is less than 50"(;

}

else{Console.WriteLine)"x equal 50"(;}

قيمة < أدخال يطبع 50عند أقل لو االولى الرسالة يطبع وهكذا الثالثة يطبع كده غير لو ......الثانية

:مثاليطبع ثم عليها حصل التي الدرجة إدخال المستخدم من يطلب برنامج بعمل قم

) , , , , ( جملة باستخدام امتياز جدا جيد جيد مقبول راسب الدرجة لتلك المقابل ؟ if التقدير:البرنامج

Console.WriteLine)" enter ur grade"(;int x = Convert.ToInt32)Console.ReadLine)((;if )x > 50({Console.WriteLine)" you are fail"(;}else if )x >= 50 && x > 65({Console.WriteLine)" your grade is accept"(;}

else if )x >= 65 && x > 75({Console.WriteLine)" your grade is good"(;}else if )x >= 75 && x > 85({Console.WriteLine)" your grade is very good"(;}else if )x >= 85 && x >= 100({Console.WriteLine)" your grade is very excellent"(;}else{Console.WriteLine)" not exist"(;}

( الدرجة إدخال عند التنفيذ (77ناتج

Switch statement:

It is similar to if statement but in another syntax.

Syntax:

Switch(variable or expression){

Case constant 1:

Statementsجملة من يخرج الحالة هذه تحقق حالة ;switch Breakفي

Case constant 2:

StatementsBreak;

ال أو وضعه :Defaultيمكن

StatementsBreak;

}

Example:Write a program by using switch case statement that ask user about the size of a sandwich (large,med,small) and then program write to him the cost of it.

Program:

string size;Console.WriteLine)" enter sandwich size)large,med,small( you want..and then press enter"(;size = Console.ReadLine)(;switch)size(

{case "large":{Console.WriteLine)"it cost 20$"(;break;}case"med":{Console.WriteLine)"it cost 16$"(;break;}

case"small":{Console.WriteLine)"it cost 10$"(;break;

}default: //)it is like else in if statement({

Console.WriteLine)" wrong choice"(;break;

{

Output:If you enter med

For statement:

الشرط حسب على المرات من معين عدد الكود من معين عدد لتكرار تستخدمالموجود

It used for repeating block of statements.

Syntax:

For(initial;condition;increment){

statements}

Example:

for (int i = 1; i <= 10;i++ ){// take the first value of i and then print it and soon...Console.WriteLine (i);

}

Output result:

Excer_

write a program by using for statement to sum the numbers from 1 to 100 and then print the summation on screen?

While statement:

It tests the condition if the condition is true go to the loop and do it if else get out the while

تتدخل صحيح لو معين شرط باختبار خارج loopتتم تخرج صحيح مش لو وتنفذهwhileجملة

Syntax:

While(Boolean-expression){

statements}

Example:

int i = 0 ;// initial valuewhile(i<5) // while I <5 enter the loop{Console.WriteLine(i); i++;}

Do-while statement:

Syntax:

جملة وبين بينها واحده whileالفرق مرة األقل على بداخلها ما بتنفيذ تقوم أنهاDo

{

statements}

While(Boolean-expression);

Example:

int x = 1;do{Console.WriteLine(x);x++;

}while (x <=5);

بين :break ,continue , goto الفرق

مثل التكرار جمل داخل ً غالبا المحجوزة الكلمات تلك for,whileتستخدمbreakأوال: من compilerتخبر البرنامج loopبالخروج داخل إليها الوصول عند Continueثانياً:

بداية إلى بالرجوع ويقوم بعدها ما يستكمل لم إليها الوصول loopعندgotoثالثاً:

بنقل تقوم إليها الوصول عند االستخدام قليلة compilerوهى

البرنامج . في معين مكان إلىExample(break):for (int i = 1; i <= 10;i++ ){Console.WriteLine(i); if (i== 5){break;}Output:

example(continue)for (int i = 1; i <= 10;i++ ){if (i == 5){continue;}Console.WriteLine(i);

}Output: وجود عدم 5نالحظ

Example:for (int i = 1; i <= 10;i++ ){if (i == 5){

goto p;}Console.WriteLine(i);p:Console.WriteLine("goto statement");

}

Methodsونريد أخرى وظيفة اى أو الطرح أو الجمع مثل معينه وظيفة بأداء يقوم كود كتابة عند

من فليس إليها الحاجة عند مره من أكثر تنفذ أن الوظيفة هذه أو الكود هذا استخدامدور يأتي فهنا إليه محتاج أنت مرة كل في الكود هذا بكتابة تقوم أن كمبرمج االحتراف

.methodال

تعريف لطريقة أو لتسمية مختلفة أنواع :methodوتوجد بعد فيما إليها سنلجأ ولكنمالحظات:

ال: تكتب داخل mainخارج methodأوال .classأو التالي بالشكلclass Program{public static int sum(int a) النوع بترجع int من ألنهاقيمة{int s = 0;for (int i = 1; i <= a;i++ ){s += i;}return s; المسود استدعاء عند ويعطيه بيها محتفظ يظل

}static void Main(string[] args)

{Console.WriteLine(" enter any numer");int x = Convert.ToInt32(Console.ReadLine ());

Console.WriteLine(sum(x)); استدعاء طريقة لما method هنااألنواع من تكون لما أو حاجة .……,int ,float بترجع

}}

من أخر نوع ارجع voidهو methodويوجد عايز مش بكون لما يستخدمه غالبا ودهالطباعة جمل مثل حاجه

class Program{public static void print(int a){

for (int i = 1; i <= a;i++ ){Console.WriteLine("i="+i);}

}static void Main(string[] args){Console.WriteLine(" enter any number");int x = Convert.ToInt32(Console.ReadLine ());

print(x); النوع من تكون لما المسود استدعاء void طريقة

}

} من أكثر وجود فأنا methodعند البرنامج من compilerداخل بينهما يفرق

حيث methodاسم

parametersعدد حيث parametersوأنواع data typeمن

قيم أعطاء طرق methodل parametersعند ثالث فهناكPassing by value, passing by reference, passing by out:

استخدام عند أكثر تستخدم الطرق النوع methodوتلك voidمنExample:class Program { public static void increment(int y)// by value { y++; لقيمة الذاكرة مكان ترى أن المسود هذه تستطيع ال

} //============================================= public static void increment(ref int y)//br ref { y++;

} //================================================= public static void increament1(out int y)//by out { y = 3; y++;

} static void Main(string[] args) { int x = 5; increment(x); Console.WriteLine(x);//x=5 //=========================================== int x2 = 5; increment(ref x2); Console.WriteLine(x2);//x=6 //==================================================== int x3 = 5; increament1(out x3); Console.WriteLine(x3);//x=4 } }

ArraysSyntax:

Data type [ ] name = new data type [ size];

Example:

int[] x = new int[4]; األراى داخل العناصر عدد عن عبارة دىarray وضع عند دائما استخدامه ويتم البرمجة في كثيرة مواضع في تستخدم

مكان داخل النوع في المتشابهة العناصر من مجموعة أو المتغيرات من مجموعة. مختلفة بطرق ترتيبه ويتم واحد

Example:

Define an array that allow to the user to enter five elements of string and then print these elements to the user?

string[] name = new string[5];for (int i = 0; i < 5; i++){Console.WriteLine("enter name number {0} ", i + 1);name[i] = Console.ReadLine();

}for (int i = 0; i < 5; i++){Console.WriteLine("the name number {0} is {1} ", i + 1, name[i]);

}من أخرى أنواع مثل arrayيوجد العناصر من متغيرة أنواع على تحتوى آن تستطيع

string,int…,…,

. معين طول لها ليس اي محدود غير بها العناصر وعدد

Array List:

Different data types and unknown it’s size.

المتغيرات من النوع في متغيره أنواع على تحتوي التي المصفوفات أنواع من هيالعناصر عدد عن عبارة هو طولها أن اى الطول معلومة غير أيضا وهى العناصر أو

داخل وضعها يتم arraylistالتى

Syntax:

ArrayList name = new ArrayList;)(

اعرف استدعى arraylistوعشان األول فى أسمها namespaceالزم

Collections طريق عن

using System.Collections;example:ArrayList arr = new ArrayList(); //define arraylistarr.Add("sayed");

arr.Add(014); لست االراى داخل اإلدخال ,.…,arraylist_name.Add(string,int طريقة…..)arr.Add(362.353);foreach(object i in arr){Console.WriteLine(i); تنوع المتغيرات حالة فى لست األراى مع يستخدم }

List:List have the same data type but unknown it’s size

Syntax: the same data typeList<data type> name = new List<data type>();

Example:

List<string> x = new List<string>();x.Add("ghada");x.Add("ali");x.Add("gdfgdg");

foreach (string i in x){Console.WriteLine(i);}

OOP(Object Oriented Programming)أل إنشاء classesطريقة

بعض classكل وهناك غيره عن بها يتميز معينه خصائص على يحتوىالمشتركة .الخصائص

: الخصائص هذه أهم منExample:

class person contain this informationengineer

teacherfarmer

doctor

Field:(body,arm,leg,noise,eye,……etc)

Property:(tall,short,size,face,……etc)Method:(work in accompany,hospital,school,……etc)Constructor:(initialize the class’s instance members)To create a new class go under the namespace in your application and .Example:class car{public int x; ببلك يكون الزم تستخدمه هاينفع ماكنش ببلك مش هنا المتغير لو}Here you are create a new class car how can you use it?In the main program you can take an object from this class ….how?static void Main(string[] args){car c = new car();// كالس اى من اوبجيكت إلنشاء العام الشكل

c.x = 4;Console.WriteLine(c.x);You can create another object from the classcar r = new car();r.x = 2;Console.WriteLine(r.x);

يستخدمها ممكن المين فى حد فأى ببلك النوع من المتغيرات تعريف عند انه الحظماينفعش يعنى فيها اتحكم اللى انا هدى الحاج اخلى محتاج انا لو طيب عليها ويغير

وخالص حاجه اى يدخل .المستخدمExample:class age{public int urage;}

………….main……………

age g = new age();// objectConsole.WriteLine("pls, enter ur age");int x = Convert.ToInt32(Console.ReadLine());g. urage = x;Console.WriteLine(g. urage);

ال من اكبر سنهم اللى غير عايز مش مثال وانا عمر اى او سن اى يدخل ممكن المستخدم ان كده وهنا 18معنىاسمها حاجه بستخدم بقا

PropertyExample:private int urage;//field

public int Age//property{get{if (urage >= 18){return urage;}else{return -1;}}set{urage = value;}}}//====================================================class Program{static void Main(string[] args){age g = new age();Console.WriteLine("pls, enter ur age");int x = Convert.ToInt32(Console.ReadLine());g.Age = x;// take the value from property.Console.WriteLine(g.Age);

internal protected private public

Change the type of age from public to private and property must be public

Access modifiers

yes no yes yes The same classyes no no yes The same name

space out the class

no no no yes Another name space

yes yes yes yes Derived class in the same name space

no yes yes yes Derived class from another name space

ConstructorIt is a method in every class gets the variable initial values by zero or null.Example:class example{public int x, y;

}

class Program{static void Main(string[] args){example ex = new example();Console.WriteLine(ex.x);Console.WriteLine(ex.y);}If I want to change the values of x or y …..create a constructor and change the values.Syntax:Public class_name(){

constructor

Change the values you want…..}Example:class example{public int x, y;public example()//constructor{x = 6; //change the value of x only but y still by zero

}}

class Program{static void Main(string[] args) {example ex = new example();Console.WriteLine(ex.x);Console.WriteLine(ex.y);}The output:

You can pass values to the constructor like the method how..?Example:

Write an application that take the name and the age from user and then print them on the screen by using constructor:class info{public string name;public int age;public info (string n,int a)// instructor have two parametrs{name = n;age = a;

}}class Program{static void Main(string[] args){Console.WriteLine("enter ur name...");string name = Console.ReadLine();Console.WriteLine("enter ur age...");int age = Convert.ToInt32(Console.ReadLine());info d = new info(name, age);Console.WriteLine("ur name is "+ d.name);Console.WriteLine("ur age is " + d.age);}}

inheritance

Name

Age

City

Degree

Name

Age

City

Name

Age

City

Department

doctor employee engineer

That mean the employee have the similar properties of the engineer and the doctor how you do this by programming…?Example:namespace inheritance{class emp //base class or the father class{public string name, city;public int age;} that mean the class eng have properties of empclass eng : emp{public string dep;} that mean the class doc have properties of empclass doc :emp //u can write class doc:eng{public string degree;}class Program{static void Main(string[] args){eng e = new eng(); //objecte.name = "ghada";e.age = 28;e.city = "alex";e.dep = "software eng.";Console.WriteLine("data:\n{0}\n{1}\n{2}\n{3}",e.name,e.age,e.city,e.dep);

}}}

Abstract Example:abstract class a{public abstract void s();//if method is abstract it must haven’t abody and also class must be abstract class

}class b:a //class b inherit from a and allow to make changes{public override void s(){Console.WriteLine("ghada");}}Example:Write application by using abstract class animal have the method eat() must be abstract and then create classes(elephent,cat,mouse) use the method eat and make changes.

Application:using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace @abstract{abstract class animal{public abstract void eat();}class eleghent : animal{public override void eat(){Console.WriteLine("elephent eat crosses");

}}class cat : animal{public override void eat(){Console.WriteLine("cat eat fish");}class mouse : animal{public override void eat(){Console.WriteLine("mouse eat cheese");}

}

class Program{static void Main(string[] args){

cat a = new cat();a.eat();

}}}}