In short: no.
C # has no concept of a const reference, as such. If you want to make an object immutable, you must explicitly encode it or use other "tricks".
You can make your collection immutable in many ways ( ReadOnlyColelction , return an iterator, return a shallow copy), but this protects only the sequence and not the data stored inside.
So you really need to do what you want to return a deep copy or scroll, possibly using LINQ:
public IEnumerable<NCPoint> TransformPoints(List<NCPoint> points, int foo, int bar, int baz) {
Also, the beauty of returning an iterator (as opposed to just returning a List<T> as an IEnumerable<T> , etc.) is that it cannot be returned to the original type of the collection.
UPDATE : or in .NET 2.0:
public IEnumerable<NCPoint> TransformPoints(List<NCPoint> points, int foo, int bar, int baz) {
The fact is that there are many ways to consider something as immutable, but I would not try to implement the C ++ version of "const correctness" in C #, or you will lose your mind. Add it as needed when you want to avoid side effects, etc.
source share