Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created April 11, 2019 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yuka1984/688973eb74fc633f516e5cfbab7181a5 to your computer and use it in GitHub Desktop.
Save yuka1984/688973eb74fc633f516e5cfbab7181a5 to your computer and use it in GitHub Desktop.
わかんないやつ
public abstract class EntityBase
{
public abstract string Name { get; }
}
public abstract class RepositoryBase<T> where T : EntityBase
{
private readonly string _name;
public RepositoryBase()
{
// ここでTのNameを_nameにセットしたい
// こういうケースってクラス名による規則で何かするか、Attributeでなんとかするかしかないのかな?
_name = Activator.CreateInstance<T>().Name;
}
public T Huga()
{
// _nameを使った処理をしたい。
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment