So I was reading through someone else's code and I was wondering if I'm right in thinking that this is just a way to initiate instances of a class easily.
private ExampleClass ex = new ExampleClass();
public ExampleClass Ex => ex;
I've been trying to mimic it - What I'm trying to run is:
class Program
{
private List<int> testList = new List<int>();
public List<int> TestList => testList;
static void Main(string[] args)
{
var testList1 = new LambdaPractice(TestList);
var testList2 = new LambdaPractice(TestList);
testList1.Print();
testList2.Print();
}
}
However, I keep getting an error that in order to use TestList
, I have to make TestList
and testList
both static variables. Why is this not the case in this person's code?
*Print is a function I implemented in the LambdaPractice
class that prints out a instance id number.