C# return a variable as read only from get; set;

后端 未结 7 2177
不思量自难忘°
不思量自难忘° 2021-02-02 07:30

I swear I have seen an example of this but have been googling for a bit and can not find it.

I have a class that has a reference to an object and need to have a GET; met

7条回答
  •  长情又很酷
    2021-02-02 08:10

    Return a reference to a stripped-down interface:

     interface IFoo
       string Bar { get; }
    
     class ClassWithGet
       public IFoo GetFoo(...);
    

提交回复
热议问题