SHARE
TWEET

Untitled

a guest Jun 19th, 2017 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public SampleIReadOnlyList
  2. {
  3.     readonly List<int> someProperty = new List<int> {
  4.         1,2,3,
  5.     }
  6.     public IReadOnlyList<int> SomeProperty {
  7.         get { return someProperty; }
  8.     }
  9. }
  10.  
  11. void foo()
  12. {
  13.     var x = new SampleIReadOnlyList;
  14.     x.SomeProperty[0] = 1; // エラー。 IReadOnlyList<T> のインデクサには setter メソッドが無い。
  15. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top