public class MyVector
{
public int X { get; set; }
public int Y { get; set; }
}
class Program
{
public static T AddVector<T>(T a, T b)
where T : MyVector, new()
{
T newVector = new T();
newVector.X = a.X + b.X;
newVector.Y = a.Y + b.Y;
return newVector;
}
static void Main(string[] args)
{
MyVector a = new MyVector();
a.X = 1;
a.Y = 2;
MyVector b = new MyVector();
b.X = 10;
b.Y = 11;
MyVector c = AddVector(a, b);
Console.WriteLine(c.X + ", " + c.Y);
}
}
Code here..
const int map_width = 20, map_height = 20;
int[,] map = new int[map_width, map_height];
// open a StreamReader to read the index
string path = Path.Combine(StorageContainer.TitleLocation, "Content\\map.txt");
using (StreamReader reader = new StreamReader(path))
{
int y = 0;
while (!reader.EndOfStream)
{
// get a line
string line = reader.ReadLine();
// split at the equals sign
string[] parts = line.Split(',');
for (int x = 0; x < parts.length; x++)
{
map[x,y] = Convert.ToInt32(parts[x]);
}
y++;
}
}