A short, maybe stupid question.
For classes and structs, sometimes I like to have member variables with the same name as constructor arguments. For example:
class Vector3
{
float x, y, z;
public Vector3(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
}
Basically, I want to do this for structs too, but you can’t use ‘this’ in struct constructors (their use is reserved for classes, I think). Is there a way to do this or should I just give my arguments another name?
You can use it, but its a pointer just as in classes:
By the way, a
structand aclassare exactly the same thing for everything but the default access specifiers.