Lazlo
Lazlo

Reputation: 8790

Forced a Reference Type to be passed by value (or .Clone()d on Pass)

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

Answers (1)

user541686
user541686

Reputation: 210643

No, you can't do that automatically, because classes are reference types by definition. You have to use a struct if that's what you want.

Upvotes: 4

Related Questions