- Home /
Create new vector types for better type checking
Is there an way to get more powerful type checking for Vectors?
I frequently introduce bugs in C# by confusing Vectors that are positions with Vectors that are are differences between positions. This seems like a problem that could be caught at compile time if I create and use some custom types.
I know that I can't extend the Vector types, that gives me errors like this:
'Vector3Diff': cannot derive from sealed type 'Vector3'
I know that I could create a wrapper class, but is there a way I could easily "pass though" the existing Vector functions so I don't have to redefine them all for the wrapper class?
I also wonder what kind of impact this would have on performance. Ideally my solution would catch errors at compile time, but after compilation it would treat them just like Vectors.
Thanks!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to add 2 Quaternions. 2 Answers