If we know that int n = myArray.Length = myList.Count
Then, when we need to use this value to represent the array/list length, which one is best to use?
e.g. do we use var x=n*2 or var x=myArray.Length*2 or var x=myList.Count*2
The equivalent question is like, would it be more efficient to directly use n instead of referring to the member property of an object?
It sounds like you’re asking the following
It’s true that a local lookup is generally more efficient than a member access. However the difference is very small and something I wouldn’t concern myself with when writing a program.
Instead focus on writing the most readable code possible. Don’t concern yourself with micro optimizations like this because they almost certainly won’t matter. You’re much more likely to find your program bottle necked at I/O, or choice of data structures than a field vs local time access difference.