Hi,

I want to call a instance method with a Action or Function delegate but it seems so that the delegates calls a static method

Code:
        private struct RoomPillar
        {
            #region Fields
            private bool _init;
            private Action<double> _valueSetterDel;
            private Func<double> _valueGetterDel;
            public int NumOfElements;
            private double _vals;
            #endregion

            public void AddValue(double v, IntermediateFilterParameter.PillarValueModeEnum pillarMode)
            {
                //init the delegate and struct
                if (!_init)
                {
                    switch (pillarMode)
                    {
                        case IntermediateFilterParameter.PillarValueModeEnum.Mean:
                            _valueSetterDel = new Action<double>(MeanVal);
                            _valueGetterDel = new Func<double>(GetMeanVal);
                            _vals = 0;
                            break;
                        case IntermediateFilterParameter.PillarValueModeEnum.Minimal:
                            _valueSetterDel = new Action<double>(MinVal);
                            _valueGetterDel = new Func<double>(GetVal);
                            _vals = double.MaxValue;
                            break;
                        case IntermediateFilterParameter.PillarValueModeEnum.Maximal:
                            _valueSetterDel = new Action<double>(MaxVal);
                            _valueGetterDel = new Func<double>(GetVal);
                            _vals = double.MinValue;
                            break;
                        default:
                            break;
                    }

                    _init = true;
                }

                _valueSetterDel(v);
                ++NumOfElements;
            }

            public double Value
            {
                get
                {
                    //at this place NumOfElements has the value 1
                    return _valueGetterDel();
                }
            }

            #region Delegates
            private void MeanVal(double v)
            {
                _vals += v;
            }
            private void MinVal(double v)
            {
                _vals = System.Math.Min(v, _vals);
            }
            private void MaxVal(double v)
            {
                _vals = System.Math.Max(v, _vals);
            }
            private double GetMeanVal()
            {
                //at this place NumOfElements has the value 0. Why???
                return _vals / NumOfElements;
            }
            private double GetVal()
            {
                return _vals;
            }
            #endregion
        }
If I invoke the method Value the variable NumOfElements has the value 1 inside this method but if I invoke the delegate this variable has the value 0. Why????

Thanks in advance