I've been trying to get on top of this for some time now and just cant figure this out.
#include <iostream>
template<class T>
struct Vec3
{
T x, y, z;
Vec3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {}
};
template <class T>
void IncVec(Vec3<T>& vec)
{
vec.x += 1;
}
int main(void)
{
Vec3<float> vec = Vec3<float>(1, 2, 3);
IncVec(vec);
std::cout << vec.x;
}
I basically want to recreate this in C#. So far I've got this:
using System;
namespace cs_playground
{
public struct Vec3<T>
{
public T x, y, z;
public Vec3(T _x, T _y, T _z)
{
x = _x;
y = _y;
z = _z;
}
}
class Program
{
public static void IncVec(ref Vec3<T> vec)
{
vec.x += 1;
}
static void Main()
{
Vec3<float> vec = new Vec3<float>(1, 2, 3);
IncVec(ref vec);
Console.WriteLine(vec.x);
}
}
}
It really doesnt like the "ref Vec3< T >" .. I mean.. it obviously works with like "ref Vec3< float >" and so on.. but I struggle with like.. passing the type I guess..
Thanks for any kind of help in advance.