c# - Using a class' "index"? -
how write code add 2 vectors , b using x,y , z co-ordinates. below code shows i'm struck exactly.
public vector(float _x, float _y, float _z) { float x, y, z; x = _x; y = _y; z = _z; vector _vector = new vector(x, y, z); } public static vector operator +(vector _a, vector _b) { return new vector(); //_a.x + _b.x , _a.y + _b.y, _a.z + _b.z }
create properties incoming parameters. can use them anywhere in class:
public class vector { public float x { get; set; } public float y { get; set; } public float z { get; set; } public vector(float _x, float _y, float _z) { x = _x; y = _y; z = _z; } public static vector operator +(vector _a, vector _b) { return new vector(_a.x + _b.x, _a.y + _b.y, _a.z + _b.z); } }
Comments
Post a Comment