KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm looking for a way to prevent a property in a C# object from being set more than once. It's easy to write the code to do this, but I would rather use a standard mechanism if one exists. public OneShot<int> SetOnceProperty { get; set; } What I want is for the property to be set if it is not already set, but to throw an exception if it has been set before. It should function like a Nullable value, where I can check to see if it has been set or not.
Tags (comma-separated)
Save Edits
Cancel