I have the following code:
public class Entity
{
public int Number;
public string Text;
}
System.Collections.Generic.List<Entity> list = new List<Entity>();
list.Add(new Entity() { Number = 100, Text = "hello1" });
list.Add(new Entity() { Number = 200, Text = "hello2" });
Entity sampleEntity = new Entity() { Number = 300, Text = "World" };
list[0] = sampleEntity // this does only replace the pointer in the list
list[0].Text = sampleEntity.Text; // this writes to the pointer in list
list[0].Number = sampleEntity.Number; // this writes to the pointer in list
What I would like to know if there is any possible way of performing a memcopy of the whole object data to the heap-location the list[0]
entry points to? I mean in c++ it is a simple dereference *list[0] = *entity;