/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/csharp/programming-guide/classes-and-structs/snippets/properties/AutoImplemented.cs
39 строк
1 KB
Bill Wagner
C# 11: required members (#30275)
29 июл 2022, 23:16
Не верифицирован
29 июл 2022, 23:16
ee56cb9
Код
Авторство
О чём код?
namespace AutoImplemented; //<snippet28> // This class is mutable. Its data can be modified from // outside the class. public class Customer { // Auto-implemented properties for trivial get and set public double TotalPurchases { get; set; } public string Name { get; set; } public int CustomerId { get; set; } // Constructor public Customer(double purchases, string name, int id) { TotalPurchases = purchases; Name = name; CustomerId = id; } // Methods public string GetContactInfo() { return "ContactInfo"; } public string GetTransactionHistory() { return "History"; } // .. Additional methods, events, etc. } class Program { static void Main() { // Initialize a new object. Customer cust1 = new Customer(4987.63, "Northwind", 90108); // Modify a property. cust1.TotalPurchases += 499.99; } } //</snippet28>