public class Client private string name private string
public class Client { ﻣﺜﺎﻝ private string name; private string id; private int age; private double salary; public Client (string name, string id, int age, double salary) { this. name = name; this. id = id; this. age = age; this. salary = salary; } public void Set. Name(string name) { this. name = name; } public string Get. Name() { return this. name; } //Get. Name public string Get. Id() { return this. id; } //Get. Id public void Set. Id(string id) { this. id=id; } //Set. Id public void Set. Age(int age) { this. age = age; }//Set. Age public int get. Age() { return this. age; } public double Get. Salary() { return this. salary; } public override string To. String() } return "name " + name + " ID: " + id + " Age: " + age +" Salary"+salary; { }//CLient
ﺃﻤﺜﻠﺔ ﻻﻭﺍﻣﺮ ﻳﺴﻤﺢ ﺍﺳﺘﻌﻤﺎﻟﻬﺎ • Client c 1=new Client("AAA", "123", 21, 5000); • Console. Write. Line(c 1. Get. Id()); • c 1. Set. Age(25); • Console. Write. Line(c 1. Get. Salary()); • c 1. Set. Id("73456"); • Console. Write. Line(c 1); Console. Write. Line(c 1. Tostring());
ﺗﻌﺮﻳﻒ ﺻﻔﺔ ﻣﻦ ﻧﻮﻉ ﻓﺌﺔ • class student { private Address address; private string name; … } Class Address { private string city; private string postal. Code; private string street; }
- Slides: 6