When writing test().xyz = xxx
you first execute test
which onbiously returns some instance of ArrayList
(btw. you should consider to use List<T>
instead nowadays, which is strongly typed and thus safes you from casting every element in your list to its actual type). Now You can of course do what you want with that instance, e.g. call another method or set any of its properties. This would be equivalent to doing this:
var val = test();
val.MyMember = 3;
However when using test() = ...
you´re assigning a new value to the return-value of the method, which clearly makes no sense.
I suppose what you want instead is provide some parameter to your method. To do so your method also should expect one:
ArrayList test(int myInt)
{
// do something with myInt
}
And call it like this:
var list = test(3);
3
solved Why left-hand side of an assignment must be a variable property or indexer? [closed]