c# - convert class string to class -
I have the code below in my ASP.NET app, I would like to change the Alternatively I can But I have around 20 unit squares and I want to find a way to write code. This will not be possible because the generic type must be specified at compile time. What you can do is to change the FillRequest method to be something like below and then use reflection to do the desired work Or take an interface to filarize Calling it something like this Oga: converter name variable For class and this is the
FillRequest & lt; T & gt; Pass in the method. Is this possible?
var converter name = HttpContext.Current.Items ["converter name"] as string; FillRequest & LT; Web2ImageEntity & gt; (Request.Params);
var converter name = HttpContext.Current.Items ["converter name"] as string; If (converter name == "web 2 image entity") filwist & lt; Web2ImageEntity & gt; (Request para);
FillRequest (string [] parameter, type converter) {// Type the object from the converter and call the req method}
FillRequest (string [] parameter, iconwise c ) {// ways to convert call c}
var type = Type.GetType (converterName); FillRequest (Request.Params, (IConverter) Activator.CreateInstance (type));
Comments
Post a Comment