Hello Experts,
I have a Console App, which imports some data thru an API call. In this all the methods are defined inside the Main(). I am trying to define some methods such as xxxSearch and XxxxDetail, return type List, outside of the Main() method. When I do that, I am getting the Error: CS0120 An object reference is required for the non-static field, method, or property 'XxxxImport.XxxxSearch(DateTime, DateTime)'.
The reason I need to do this, because I need to convert this to a Windows Service Program comfortably.
Please let me know how to define them outside of Main() method and call them,
Thank you very much in advance.
Below is the Skeleton of the Code
----------------------------------------------------
public static void Main(string[] args)
{
DataSet ds = new DataSet();
var fromDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddDays(-1);
var toDate = DateTime.Parse(fromDate.ToString("yyyy-MM-dd")).AddDays(0);
MainHub(fromDate, fromDate);
Environment.Exit(0);
void MainHub(DateTime FromDate, DateTime ToDate)
{
var xxxFound = xxxSearch(FromDate, ToDate);
if (xxxFound != null)
{
InsertxxxRaw(xxxFound, FromDate);
}
foreach (var xxx in xxxFound)
{
var list = new List<string>();
list.Add(xxx.xxxNumber);
var details = xxxDetail(xxx.validatingxxxDesignator, list);
if (details != null)
{
InsertDetailTableRaw(details);
}
}
}
IList<Xxxx> xxxSearch(DateTime from, DateTime to)
{
IList<Xxxx> searchResults = new List<Xxxx>();
try
{
while (true)
{
}
}
catch (SqlException ex)
{
}
return searchResults;
}
IList<XxxxDetail> XxxxDetail(string yyyCode, List<string> xxxNumber)
{
.
.
.
return detailResults;
}
}
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.