What is the C# equivalent of the following C++ code?

Started by
1 comment, last by Spa8nky 12 years, 2 months ago

char* trailFlags; // array of flag bits for trail points
.....

bool someBool = CalculateBool();

trailFlags[index] = someBool ? 2 : 0;


I'm unsure as to how the integer value of 2 or 0 is stored as a flag bit char in C#. 0 appears to be stored as '0x002f6020' in C++.

How would I do the same in C#?
Advertisement
This should work the exact same way in C#. I'd wager you're looking at the value of trailFlags rather than the value of trailFlags[index] - these are not the same. trailFlags is the memory location that the data is stored at, trailFlags[index] is the actual data.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

in C# you can use pointers but unless you need to typesafe arrays are the better choice


int[] trailFlags = new int[flagLength];
bool someBool = CalculateBool();
trailFlags[index] = someBool ? 2 : 0;

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

I'd wager you're looking at the value of trailFlags rather than the value of trailFlags[index] - these are not the same[/font]


[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[/quote]

[/font]

I see now. My C++ experience is 'null'. :)

This topic is closed to new replies.

Advertisement