Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement