C# Brainwrong

How do I do this in C#

I have an ArrayList and the following code :

levelObject objtest;

objtest = (levelObject)levelObjectList[10];

objtest.matWorld = Matrix.Identity;

I want the matWorld of the 10th element of the arraylist to change to identity when I change the objtest.matWorld.

I thought objects were references and not value types.



Answer this question

C# Brainwrong

  • MMCompton

    I didn't even notice that ha. My biggest pet peeve is the dreaded, make me hold down shift and blow my intellisence to bits m_ and _property grrr
  • Oli_c

    Don't mean to be picky but you should really use pascal case for your class names, LevelObject would be more appropriate.

    Sorry, had to mention it ;)


  • brajeshkumar69

    Yep, that's why, change it to a class and it should work fine.
  • Anton__

    Well, given the code above, you would be operating on the 11th item in the arraylist, as arraylists are 0 based. Other than that, without seeing the rest of your code, It's impossible to know what you're trying to do.


  • prozac11

    Maybe it's because my levelObject type is a struct

    public struct levelObject

    {

    public Matrix matWorld;

    public BoundingSphere sphereWorld;

    }


  • Chris Honcoop

    Yes, that would be the 11th item, my bad :)

    I'm just trying to store a reference to a single item in an arraylist and then change that items values via the reference ie similar to a pointer to an array element in C.


  • C# Brainwrong