title: return object from method in class
body: <p>I have a code which is made of 2 classes. inside the <code>class Program</code> there is a method names <code>calculate</code> which should get 3 strings and return an object:</p>
  
  <pre><code>namespace ConsoleApplication1
  {
      public class DataGridObject
      {
          public string MainName { get; set; }
          public double Level { get; set; }
          public double Exp { get; set; }
          public double AmountNeed { get; set; }
          public double TotalLose { get; set; }
          public double TotalGain { get; set; }
          public double TotalCost { get; set; }
          public Uri ImageSource { get; set; }
  
      }
  
     public static class Program
      {
  
              public object calculate(string db_name, string sheetname, string images_path)
              {
  
              string DataBase_File = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory.ToString(),     String.Format("{0}",db_name));
              string SheetName = string.Format("{0}$",sheetname);
              string Images_File = string.Format(@"{0}",images_path);
  
              ***//some code in between which reads url, parsing json and do some math on the data in order to store it in `var d`//*** 
  
              var L = new List&lt;DataGridObject&gt;();
  
              string[] filePaths = Directory.GetFiles(Images_File);
  
              for (int z = 0; z &lt; list_Exp.Count; z++)
                {
                  var d = new DataGridObject();
  
                  d.MainName = ...;
                  d.Level = ...;
                  d.Exp = ...;
                  d.AmountNeed = ...;
                  d.TotalLose = ...;
                  d.TotalGain = ....;
                  d.TotalCost = ....;
                  d.ImageSource = new Uri....;
  
                  L.Add(d);
  
                }
  
              return L;
  
            }
  
  
  //calling the method:
  
      string db_name = "DataBase.xlsx";
      string sheetname = "sheet1";
      string images_path = "C:\\Users...";
  
      object a = calculate(db_name, sheetname, images_path);
  
  }
  </code></pre>
  
  <p>The error i get is at the line where i call the method:</p>
  
  <p>"A field initializer cannot reference the non-static field,method or property <code>Program.db_name</code>" and same for the 2 others (Program.sheetname, Program.images_path)</p>