Not sure if I worded this correctly … but I have the following code:
public Guid ItemId { get; } public TransactionItem() { this.ItemId = Guid.Empty; }
Naturally I am getting a read-only issue … which I do understand. Is there anyway to set this property value without having to do something like the below:
Guid _itemId = Guid.Empty; public Guid ItemId { get { return _itemId; } set { _itemId = value; } }
or
public Guid ItemId { get; internal set; }
Thanks in advance!
I would go for this:
Of course, it would be open for setting within this class, but since you are writing it I hope you have the sense to not break your own intentions…
In my opinion, things like readonly properties, are mostly important when seen from the outside. From the inside, it doesn’t really matter what it is, cause there, you are the King =)