I am slightly new to the reflection, so please forgive me if this is another basic question that I have a program in C I am writing and trying to write a simple blank or empty tester method, so far the code
public static class EmptyNull {public static bool blank neal checker (object o) {try {var Ob = (object []) o; If (obe == weaken! | Ob. Someone ()) Truth back; } Hold (Exception E) // I can use genercs to figure out if it is an array but / i just detected the exception to capture {console. WrightLine (E);} {try (Gettype O)) GetGenericTypeDefinition () .Equals ("System.Collections.Generic.List`1 [T]"))) // The following line is where the code goes haywire Var ob = (list & lt; o.gettype (). GetGenericArguments () [0] .ReflectedType & gt;) o; If (obe == weaken! | Ob. Someone ()) Truth back; } Hold (exception e) {Console.WriteLine (e); } Return o == faucet || Ostosting (). equal (""); // The only thing that can return after the string () is a string that = "", if its empty objects will return, marker}} Now a list clearly For that I should know what kind of generic list is, so I want to use the reflection to understand it and then it is possible to put it with that reflection. It is possible
thanks
If you want all If the only method that returns the truth is no object empty or if the object is an empty Gnnaiogy, so I will not use reflection to it. How about a couple of expansion methods? I think this would be cleaner:
public static class extension {public stable bull} ISNullOrEmpty (this object obj) {obj == faucet; } Public Static Bull ISILORACITY & lt; T & gt; (This is IEnumerable & lt; T & gt; obj) {return obj == faucet || ! Obj.Any (); }}
Comments
Post a Comment