Q:

C# update object in list

I have a repository with a public List<someView> list;
Is it not possible to get an item with linq like this and just update/replace the whole object so the object in the list is updated globally right away?
...
var item = list.SingleOrDefault(m => m.Id== viewModel.Id);
if (item != null)
{
    item = viewModel;
}
...

A:

No because item is just a local variable, but you can use the indexer of the list:
int index = list.FindIndex(m => m.Id == viewModel.Id);
if(index >= 0)
    list[index] = viewModel;

