Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public abstract class EntityBase
  2. {
  3. public abstract string Name { get; }
  4. }
  5.  
  6. public abstract class RepositoryBase<T> where T : EntityBase
  7. {
  8. private readonly string _name;
  9.  
  10. public RepositoryBase()
  11. {
  12. // ここでTのNameを_nameにセットしたい
  13. // こういうケースってクラス名による規則で何かするか、Attributeでなんとかするかしかないのかな?
  14. _name = Activator.CreateInstance<T>().Name;
  15. }
  16.  
  17. public T Huga()
  18. {
  19. // _nameを使った処理をしたい。
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement