Reputation: 8790
I have a math class (Vector3) that represents the 3 axis (x-y-z) with 3 floats. I would like it to be forced passed as value, not reference, since it's really just... A value, not an object. Any way of doing that automatically? I know I can do .Clone() in each of my methods, but you understand this isn't optimal.
Upvotes: 1
Views: 953
Reputation: 210643
No, you can't do that automatically, because class
es are reference types by definition. You have to use a struct
if that's what you want.
Upvotes: 4