© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
15 replies
corey

❔ Can you modify fields in a struct?

I am working on a school project and have run into an issue. Code snippets is: https://sourceb.in/SsaOkq7M8I

This line,
game.quantityInCart++;
game.quantityInCart++;
doesn't actually change the variable. When I print it
Console.WriteLine($"{game.quantity} - {game.quantityInCart}");
Console.WriteLine($"{game.quantity} - {game.quantityInCart}");
it is always 0. Can variables in a struct not be modified ?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Struct Fields
C#CC# / help
4y ago
❔ StructureMap.StructureMapException: StructureMap Exception Code: 207
C#CC# / help
3y ago
❔ static fields for struct types
C#CC# / help
4y ago