Class Practice
unknown
csharp
a year ago
1.7 kB
14
Indexable
Company[] companies = new Company[] { new Company() { Name = "APro Academy", Email = "Apro@gmail.com", Location = new Location("Kazakhstan", "Atyrau", "Avangard", "40") }, new Company() { Name = "BPro Academy", Email = "Bpro@gmail.com", Location = new Location("Canada", "Vancuver", "Street 2", "23") }, }; Person alemkhan = new Person() { FirstName = "Alemkhan", LastName = "Utepkaliyev", Email = "Alemkhan@gmail.com", Company = companies[0], Location = new Location("Kazakhstan", "Atyrau", "Nursaya", "23"), BestFriend = new Person() { FirstName = "Tom" } }; Person sam = new Person() { FirstName = "Sam", LastName = "Samski", Email = "Sam@gmail.com", Company = companies[1], Location = new Location("Kazakhstan", "Atyrau", "Satpaeva", "13"), BestFriend = alemkhan }; Console.WriteLine(sam.BestFriend.BestFriend.FirstName); // Физ. адрес: Страна, Город, Улица, Дом public class Person { public string FirstName; public string LastName; public string Email; public Company Company; public Location Location; public Person BestFriend; } public class Company { public string Name; public string Email; public Location Location; } public class Location { public string Country; public string City; public string Street; public string Building; public Location(string country, string city, string street, string building) { Country = country; City = city; Street = street; Building = building; } }
Editor is loading...
Leave a Comment