Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Value versus Reference
Message
De
13/09/2010 13:48:09
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Value versus Reference
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01481001
Message ID:
01481001
Vues:
96
Hi,

If I want to store a value retrieved for later and it is a reference type value, how can I convert this to a value? Here is what I mean.
DataSet dsSmith = this.oContact.GetContactByLastName("Smith");
Session["dsSmith"] = dsSmith

DataSet dsMiller = this.oContact.GetContactByLastName("Miller");
Session["dsMiller"] = dsMiller;

// Get the dataset back from the session
DataSet dsGetSmith = (DataSet)Session["dsSmith"];

DataSet dsGetMiller = (DataSet)Session["dsMiller"];

// Both dsGetSmith & dsGetMiller have the exact same dataset.
When the first dataset is retrieved and saved in the session the value is as expected. When the second dataset is retrieved the first dataset that was saved is replaced because it was a reference. How can I copy a dataset to a value so it does not get a reference update?
Thanks
Tim
Timothy Bryan
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform