fork download
  1. using System;
  2.  
  3. public class Repository: Key.CreateProxy{
  4.  
  5. public void Add(int data){
  6.  
  7. Key key = Create();
  8.  
  9. // 以下データの保存処理とか
  10. }
  11. }
  12.  
  13.  
  14. public class Key{
  15.  
  16. public int Value{get; private set;}
  17.  
  18. // 外部からの生成禁止
  19. private Key(int i){
  20. Value = i;
  21. }
  22.  
  23. // このプロキシを継承したクラスでしか生成できない
  24. internal class CreateProxy{
  25. static int s_Increment = 0;
  26.  
  27. protected static Key Create(){
  28. return new Key(s_Increment++);
  29. }
  30. }
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(3,14): error CS0060: Inconsistent accessibility: base class `Key.CreateProxy' is less accessible than class `Repository'
prog.cs(24,17): (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty