Unknown error message

Hi Experts,

What does the error message (below) mean? It is generated by the attached code snippet.

Error      1      An object reference is required for the non-static field, method, or property 'ConsoleApplication1.Program.DoRating(double, double, int, double, double, int, double)'

 
static void Main(string[] args)
        {
            var RatingResult = new RatingQuad();

            RatingResult = DoRating(30.123, 1.123, 1, 25.123, 1.123, 0, 28.7);

        }

Open in new window

DColinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sfaisalawanCommented:
Dear The Object you are going to create Rating Result is wrong. do this

RatingResult rs=new RatingQuad();
rs.DoRating(.....................);

First you are assigning RatingResult =new RatingQuad();
and then RatingResult=DoRating(.............);
which is wrong.
you are creating new object not a new variable.
DColinAuthor Commented:
Hi sfaisalawan:

I have changed the code as you suggest (see attached) and I get the following error message.

Error      1      The type or namespace name 'RatingResult' could not be found (are you missing a using directive or an assembly reference?)

 
static void Main(string[] args)
        {
            RatingResult rs = new RatingQuad();

            rs.DoRating(30.123, 1.123, 1, 25.123, 1.123, 0, 28.7);

        }

Open in new window

sfaisalawanCommented:
this is asking for a class which have the definition of RatingQuad(); object. have you make any class in your program.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

DColinAuthor Commented:
Hi

Yes I have created the RatingQuad class. Here is all the code.
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Moserware.Skills.Numerics;
using Moserware.Skills.TrueSkill;
using Moserware.Skills;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var RatingResult = new RatingQuad();

            RatingResult = DoRating(30.123, 1.123, 1, 25.123, 1.123, 0, 28.7);

        }

        private RatingQuad DoRating(double homeMu, double homeSigma, int homeScore, double awayMu, double awaySigma, int awayScore, double drawPercentage)
        {/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            TwoPlayerTrueSkillCalculator calc = new TwoPlayerTrueSkillCalculator();

            var player1 = new Player(1);
            var player2 = new Player(2);
            var gameInfo = GameInfo.DefaultGameInfo;
            var RatingResult = new RatingQuad();

            gameInfo.DrawProbability = drawPercentage / 100;

            Team team1 = new Team(player1, new Rating(homeMu, homeSigma, 3));
            Team team2 = new Team(player2, new Rating(awayMu, awaySigma, 3));

            int Param0 = 0;
            int Param1 = 0;

            int scoreR1 = homeScore;
            int scoreR2 = awayScore;

            if (scoreR1 > scoreR2)// Home win.
            {
                Param0 = 0;
                Param1 = 1;
            }
            else if (scoreR1 < scoreR2)// Away win.
            {
                Param0 = 1;
                Param1 = 0;
            }
            else if (scoreR1 == scoreR2)// Draw.
            {
                Param0 = 0;
                Param1 = 0;
            }
            //else
            //{
            //    MessageBox.Show("buttonCalculate_Click() Error: winType not recognised.");
            //}

            var newRatings = calc.CalculateNewRatings(gameInfo, Teams.Concat(team1, team2), Param0, Param1);

            foreach (KeyValuePair<Moserware.Skills.Player, Moserware.Skills.Rating> pair in newRatings)
            {

                if (pair.Key.ToString() == "1")
                {
                    RatingResult.homeMu = Convert.ToDouble(pair.Value.ToString().Split(',')[0].Split('=')[1]);
                    RatingResult.homeSigma = Convert.ToDouble(pair.Value.ToString().Split(',')[1].Split('=')[1]);
                }

                if (pair.Key.ToString() == "2")
                {
                    RatingResult.awayMu = Convert.ToDouble(pair.Value.ToString().Split(',')[0].Split('=')[1]);
                    RatingResult.awaySigma = Convert.ToDouble(pair.Value.ToString().Split(',')[1].Split('=')[1]);
                }

            }

            return RatingResult;

        }

    }

    public class RatingQuad
    {

        public double homeMu;
        public double homeSigma;
        public double awayMu;
        public double awaySigma;

    }//public class RatingQuad

}

Open in new window

PryratesCommented:
make DoRating static and you should be fine

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PryratesCommented:
if that solves the problem, grant points to sfaisalawan please and not to me, because he was much more a help than me :-). I was just *hopefully* nailing it down.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.