title: In C#, how can you have a global generic class?
body: <p>So I have a base set of abstract classes using BaseEngine namespace, and the real game project deriving the set.</p>
  
  <p>There are many base classes that have a set of abstract methods and predefined methods such as:
  Item, Entity, Skill</p>
  
  <pre><code>public abstract class Item 
  {
      public string name;
      public void DestroyItemInBaseEngine () 
      {
          // bunch of codes
      }
      public abstract void BakeItemTheWayYouWant ();
  }
  
  public abstract class SkillManager
  {
      public abstract T InteractItemWithSkill&lt;T&gt; (T item)
          where T:Item, new(); //not sure if this particular line is valid, but this was written just to help you understand
  }
  </code></pre>
  
  <p>And deriving classes such as:</p>
  
  <pre><code>public class GameItem : Item
  {
      public int variableSpecificToThisGameProject;
  
      // and other implementation for this specific game...
  }
  </code></pre>
  
  <p>Now, Within BaseEngine, it would have abstract classes that refer Item multiple times in managers like BaseItemManager. Each game would manage differently so these managers must be derived as well. When a specific game project derives BaseItemManager, it would have to use GameItem.</p>
  
  <p>BaseEngine was created to be able to be used with different projects, a basically set of abstract classes. </p>
  
  <p>Every time when these derived objects are being referred in the game project, you either have to cast it, or use generic type in abstract methods like such:</p>
  
  <pre><code>if (ValidateItemObject&lt;GameItem&gt; (GameItem item) != null)
      // do something with it
  </code></pre>
  
  <p>So because GameItem and other types are decided at compile time, is there anyway to declare something like T = GameItem, S = GameSkill for the entire project so we don't have to mention  every time related methods (like above) or classes are called?</p>
  
  <p>I tried my best to make my case as clear as possible, but let me know if isn't clear what I'm trying to do.</p>
  
  <p>EDIT:</p>
  
  <pre><code>protected abstract T ConvertTableToItem&lt;T&gt; (T item, LuaTable luaTable) where T:BaseItem;
  
  
  protected override ProjectItem SetItemAPI&lt;ProjectItem&gt; (ProjectItem newItem, LuaTable luaTable)
  {
      newItem.desc = "test";
  }
  </code></pre>
  
  <p>This wouldn't work saying desc is not a member of the class. I can guarantee that it is. desc (public string desc) is defined in ProjectItem.</p>
  
  <p>ProjectItem is a derived class of BaseItem.</p>