0

I did reverse engineering of a project using .NET Reflector everything is fine Instead of this error I don't know how I can solve it please guide me Thanks in Advance. Here is the code.

CS0212 You can only take the address of an unfixed expression inside of a fixed statement initializer

if (flag6 && !double.IsNaN(doubleValue))
{
  double* numPtr1 = &this._MeasData[index].MeasValSum;//Error(You can only take address of an unfixed expression inside of a fixed statement initializer)
  numPtr1[0] += doubleValue;
  int* numPtr2 = &this._MeasData[index].MeasValNoOfValues; //Error(You can only take address of an unfixed expression inside of a fixed statement initializer)
  numPtr2[0]++;
}

and the _MeasData Struct is

[StructLayout(LayoutKind.Sequential)]
private struct MeasChData
{
  public MeasureInfo MeasInfo;
  public int MeasChNumber;
  public RollingPointPairList MeasureSamples;
  public LineItem MeasuredValueLine;
  public double MeasValSum;
  public int MeasValNoOfValues;
  public double MeasValLabel;
  public double CurrentYMin;
  public double CurrentYMax;
}

I tried casting but failed to sort out this error. I'm not good in English. So ignore if.... Thanks

Igor
  • 60,821
  • 10
  • 100
  • 175
buddy
  • 418
  • 4
  • 10
  • 29

1 Answers1

0

I have fixed the problem this way

fixed(double* numPtr1 = &this._MeasData[index].MeasValSum)
numPtr1[0] +=doubleValue;
fixed( int* numPtr2 = &this._MeasData[index].MeasValNoOfValues)
numPtr2[0]++;
buddy
  • 418
  • 4
  • 10
  • 29