Error 1 An object reference is required for the non-static field, method, or property
Error 1 An object reference is required for the non-static field, method, or property 'ConsoleApplication_FileTest.Program.GetAverageSalary(string)' C:\Users\Dawn\documents\visual studio 11\Projects\ConsoleApplication_FileTest\ConsoleApplication_FileTest\Program.cs 98 24 ConsoleApplication_FileTest
static void Main(string[] args)
{
Dictionary<string, double> averages = new Dictionary<string, double>();
string filename = "c:\\test.txt";
averages = GetAverageSalary(filename)
}
=====================
Dictionary<string, double> GetAverageSalary(string filename)
{
...
Re: Error 1 An object reference is required for the non-static field, method, or prop
The Main() method is static, GetAverageSalary() is not, so it can't be called without an object.
Just add "static" in front of the declaration of GetAverageSalary() - just like the one Main() already present in front of Main().