いくつかのプロパティを持つ がobject
あり、それらのプロパティのいくつかはLists
です。各リストには、他のクラスのインスタンスが含まれています。私がやりたいことは、リストから最初の項目を取得し、それらのプロパティ値を上書きすることです。
これが私が持っているものの疑似例です:
public class User
{
public List<Address> Addresses = new List<Address>();
public User ( )
{
Addresses = fill with data;
}
}
public class TestUser
{
public User user; // Is filled somewhere in this class
public void TestUpdateList ( Address addr )
{
// The param "addr" contains new values
// These values must ALWAYS be placed in the first item
// of the "Addresses" list.
// Get the first Address object and overwrite that with
// the new "addr" object
user.Addresses[0] = addr; // <-- doesn't work, but should give you an idea
}
}
この例が、私がやりたいことを明らかにしてくれることを願っています。
だから私は基本的にリスト内の既存のアイテムを「更新」する方法を探していobject
ます。