How To Return A Class With Static Members
-
Suppose in my project I'm referencing another project as follows:
using static ProjectA;
Prior to using the static keyword in the using statement, one of my methods was able to create an instance object of a class called Products, set the values of its members, and return the instance object as shown below:
Product prod = new Models.Product();
prod.ID = unit.ID;
prod.Dept =unit.Department;
return prod;Now I'm getting errors saystating that I cannot use an instance object to access members of the Product class. I tried to resolve this by going to the Product class in ProjectA and added the static keyword to the ID and Dept properties. But the big problem now is I do not have the instance object of the Product class so I cannot return it and I get an error related to that. How do I return the Product class instance in this situation?