c# - IEnumerable from object which is IEnumrable -


I have a way that takes (object value) and it's string with some difficult rules

relates to one of those rules when the value is IEnumerable . In this case, I have to process each item on the following:

  public string convert (object value) {var valuetype = value.GetType (); If (value-typeGateInterface ("ILIT")! = Null) {var e = (INMONABLE; Lt; Object & gt;) value; Return E.Count () == 0? "": E. Selection (o = & gt; Convert (o)). Total ("", (c, s) => c + s);   

Of course, if the value is list & lt; String & gt; , for example, line

var e = (IEnumerable & lt; Object & gt;) value;

throw an exception

Unable to remove type of object 'System.Collections.Generic.List`1 [System.String]' to type For 'System.Collections.Generic.IEnumerable`1 [System.Object]'.

Any ideas, how can I get rid of it?

something like

var e = ((IEnumerable) value) .Cast & lt; Object & gt; ()

Although I think this bill may fit:

  convert public static string (object value) {if (value is string) Return value. Toasting (); Var data = value as IEnumerable; If (Data == empty) return string. Empty; // I think you forgot this one var e = data Cast & lt; Object & gt; (); Return E.Count () == 0? String Empty: E. Selection (o = & gt; Convert (o)). Total ("", (c, s) => c + s); }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -