using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace ConsoleApplication11
{
class Customer
{
public List<string> Strings
{
get;
} = new List<string>();
class Program
{
static void Main(string[] args)
{
Customer myCustomer = new Customer();
myCustomer.Strings.Add("test");
}
}
}
}
最後に、コレクションStrings
をset
なしでプロパティ宣言に追加できます。なぜC#のようなデザインですか? collection
が正常な性質のように機能するかどうかを理解することは簡単でしょう。コレクションプロパティを設定せずに変更できるのはなぜですか?
この回答は少しばかり分かりにくいので、混乱しています。 – Enigmativity
@Enigmativityそれは公正です。ご意見をいただきありがとうございます。 –