我创建了一个名为Colors的类。我正在设置Colors对象上的某些属性,并将其设置为Session变量。当我在另一个页面访问Session变量时,我注意到如果我更改下面objColors上的属性,它会更改Session并且不会保留原始属性,而这正是我想要的结果。以下是一个示例:
Session["Colors"] = Colors;
Colors objColors = Session["Colors"];
//If I change objColors, it changes the Session. I don't want this to happen.
有没有更好的方法来保留原始属性?为什么会这样做?