c# - Does changing a copy of a variable change the original? -
i had access modified closure error in code below
foreach (var user in entities.user) { bool = entities.person.any( p => p.name == user.name); } so changed
foreach (var user in entities.user) { user theuser = user; bool = entities.person.any( p => p.name == theuser.name); } now, question want able modify property of user object. matter if either of following. both save down database when call savechanges on dbcontext?
user.property = 1; or
theuser.property = 1;
yes. user in case referencec type , variables of type references pointing instance. assignment changes variable point same instance.
Comments
Post a Comment