考虑代码和输出:
using Microsoft.Xna.Framework;
//Where color is from ^ that
static Color color = new Color(0, 0, 0, 0);
static void Main(string[] args)
{
Color otherColor = color;
color.B = 100;
Console.WriteLine(otherColor.B);
Console.WriteLine(color.B);
Console.ReadLine();
}
//output
//0 <-- otherColor
//100 <-- color
但是,我希望 otherColor 通过引用携带相同的值,这样输出将变为
//100
//100
如果可能的话,我怎么能做到这一点?