Object passed by reference unexpectedly
Why is the context of
aa modified when contextcontext is modified?c#
TokenContext context = new TokenContext(0,1,0,0,src); // start = 0
Token a = new Token(new SortedSet<int>{0,1}, new List<Token>{}, context);
context.start = 1;
context.end = 2;
Token b = new Token(new SortedSet<int>{1,2}, new List<Token>{}, context);
Console.WriteLine(a.context.start); // 1
Console.WriteLine(b.context.start); // 1c#
TokenContext context = new TokenContext(0,1,0,0,src); // start = 0
Token a = new Token(new SortedSet<int>{0,1}, new List<Token>{}, context);
context.start = 1;
context.end = 2;
Token b = new Token(new SortedSet<int>{1,2}, new List<Token>{}, context);
Console.WriteLine(a.context.start); // 1
Console.WriteLine(b.context.start); // 1