Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object parameter doesn't change its values
Message
 
 
To
All
General information
Forum:
C#
Category:
Coding, syntax and commands
Title:
Object parameter doesn't change its values
Miscellaneous
Thread ID:
01657570
Message ID:
01657570
Views:
38
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
Reply
Map
View

Click here to load this message in the networking platform