How do i modify a field in a property that is a struct?
For example:
using System;
using System.Collections.Generic;
namespace ConsoleApplication1
{
struct vector
{
public vector(int theX, int theY)
{
x = theX;
y = theY;
}
public int x;
public int y;
}
class SomeClass
{
public vector myVector { get; set; }
public SomeClass()
{
myVector = new vector(10, 20);
}
}
class Program
{
static void Main(string[] args)
{
SomeClass me = new SomeClass();
me.myVector.x = 200; //Error
Console.Read();
}
}
}
If the vector was a class, then i would be able to modify it.
So my question is: How can i modify it if it was a struct?
So far, my solution would be setting my current vector to a new vector
for example (if i only wanted to modify the x value):
me.myVector = new vector(200,me.myVector.y);