Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Object parameter doesn't change its values
Message
 
 
À
Tous
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Titre:
Object parameter doesn't change its values
Divers
Thread ID:
01657570
Message ID:
01657570
Vues:
37
Hi everybody,

I have the following method:
[Route("")]
        [HttpPost]
        public IHttpActionResult CreateMax4Sale(EditMax4SaleViewModel max4saleViewModel)
        {
            var conflicts = ChangeMax4Sale(max4saleViewModel, "Add");

            if (conflicts == 0)
            {
                return Ok(max4saleViewModel);
            }

            return ThrowError(conflicts);
        }
In the ChangeMax4Sale method I have at the bottom:
max4saleViewModel = GetModel(max4sale);
At this point when I examine max4SaleViewModel variable I can see that its Id is properly set to the new Id.

However, when I examine it back in the calling method, I see the Id is back to 0.

What am I missing here and how can I make sure that my variable is properly updated? Should I explicitly pass it by reference?

Thanks a lot in advance.

UPDATE. Adding ref keyword to the method and the call fixed the issue.
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform