Hi,
I am just learning C# and I have a problem now. :-) In C++ I loved to use "const reference" as a parameter to avoid that the called method changes my passed object.
I read somewhere that I can do sth. similar in C# by using Interfaces. In the interface I would just put some "getters" to allow the method a readonly access to my object.
Now guess, that I want to pass my C# method a built-in container like "List". But I want to avoid that the method changes something in that list. Just read only!
My first thought was: - I create a new Interface called IMyOwnInterface, which uses the interface IList as well
My new interface IMyOwnInterface contains only "getters"
I change my method to sth. like that MyLittleMethod(IMyOwnInterface if)
Now the method "MyLittleMethod" can just see the "getters", which I put in my own interface and not the "setters" of IList
Is this possible? Can someone give me a hint?