c# - Can we use the value of GetType().ToString() as an identifier to get an object? -


Hello, I have an object that has been obtained from the new Sword () with the intangible class item. Can I somehow use a string property name or this. GetType () To refer to a continuous object from another object (static) as ToString () identifier. I have an object from another stable orbit to refer to a bitmap image provided as a System.Drawing.Bitmap object. Here I have the code:

Actually:

  // WORKS return heroes prototype. MapConsts.Bitmaps.sword; // no string name string = "sword"; Return heroesportotype.map console Bitmaps & Lt; String Name & gt; // More in details: Abstract class item: drawable // class item in this case will serve as the guardian for all items (ax, sword, employee etc.) New sword () {public string name {get; Set; } / / Assets that I want to use to identify with identifier bitmap Drawable.GetSprite () // method that succes to all types of objects {return HeroesPrototype.mapConsts.Bitmaps. & Lt; String Name & gt; // name = "sword" is my object identifier}} namespace heroespotepip.map constests {public static class bitmap {public static system. Drawing Bitmap Castle = New System Drawing Bitmap (bitmapfilefile (@ ".. .. .. .. sprites \ mapobj \ sword.png")); }}  

If I think right you need access and something like that

  Bitmap Dryer. Gatesprit () {Return (bitmap) (typeoff (diamondspotopypropion.map cons. Bitmap) .GetField (Name) .GetValue (null)); }  

Comments