C#C
C#3mo ago
Attikitty

✅ Basic Design Question on Vectors

As a learning project I wanted to implement some basic vector data types. I had made a rudimentary Vector2D and Vector3D class, and was making dynamically sized Vector class when I had this question.

Would it be possible to have a statically sized vector class that can work with multiple sizes? For example, I could create an instance of VectorN with 2 dimensions and an instance of VectorN with 5 dimensions and if I tried to add them it would error in compile time.

With my very introductory knowledge of C# my best guess is with attributes and reflection, but I'm not sure and thought I'd ask.
Was this page helpful?