   ListStructure Problem in C#
  I have a list variable of a structure type, and I want to change the value of a variable inside the structure of a part of the list at position 'index'. But I keep getting a compiler error:Quote:Error1Cannot modify the return value of 'System.Collections.Generic.List<SpriteList.SpriteProperties>.this[int]' because it is not a variableC:\Documents and Settings\Zmurf\My Documents\Visual Studio 2005\Projects\MarioGame\MarioGame\Sprites.cs579MarioGameHeres my code:    protected struct SpriteProperties    { public Texture2D m_sTexture;   public int m_sHeight, m_sWidth, m_sX, m_sY;   public int m_sFrames;   public SpriteEffects m_sEffects;   public SpriteBlendMode m_sBlendMode;   public SpriteProperties(Texture2D texture,  int width, int height, int x, int y, int frames,  SpriteEffects effects, SpriteBlendMode blendmode)   {  m_sTexture = texture;  m_sWidth = width;  m_sHeight = height;  m_sX = x;  m_sY = y;  m_sFrames = frames;  m_sEffects = effects;  m_sBlendMode = blendmode;   }    };    List<SpriteProperties> m_Sprites;public void SpriteEffect(int index, SpriteEffects effect)    {   m_Sprites[index].m_sEffects = effect;    }I've looked at the error help and did what they suggested but it did not work ,then I tried referencing the SpriteEffect in the array's structure but that just got me even more errors, I'm new to C# because I want to try the XNA Game Studio.   
  If you're familiar with C++, you're trying to do something likeint f(){    return 0;}f()++;In your C# code, you have a list of structs. When retrieving an element, you receive a (temporary) copy of the element (because structs are "value types"), and you're trying to modify this temporary variable. Theoretically, this should be possible, but it's a good thing the C# compiler considers this an error, since modifying a temporary value is seldom what you want to do.In summary, modifying a value requires you to have access to its l-value, which you don't have when working with structs.   ;  So how can I get around this?EDIT:Wait, I did it. I had to replace that index in the lsit with a whole new Structure instance identical to the previous one but changing only the value I want.   ;  Yes, that's one solution. Another way would be to turn the struct into a class, or use some sort of boxing (I'm not sure how it would work with the automatic boxing in C#, but you can certainly make it work if you do it manually).   