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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -