I have an observation which I couldnt figure what I am doing wrong with the way I am using List.
I have a list of a Custom Object called 'CalculateObj' as follows.
public List<CalculateObj> DoSomething(int case1)
{
public List<CalculateObj> obj = new List<CalculateObj>();
switch(case1)
{
case 1 :
await DoSomethingElse(obj)
break;
}
//Now this obj has count as 0
return obj;
}
public Task DoSomethingElse(List<CalculateObj> obj)
{
obj = await //Call a db table and populate
//This obj has 5 items
}
I am creating List<CalculateObj> in DoSomething() and passing to DoSomethingElse() .
In the DoSomethingElse() I see the list is populated with 5 rows.
But when the control goes back to DoSomething() , obj count is always 0. Why is this happening? Arent lists supposed to be Reference type?