c# Programming Glossary: o.gettype
C# Using Reflection to copy base class properties http://stackoverflow.com/questions/1198886/c-sharp-using-reflection-to-copy-base-class-properties o MyObject copyObject ... FieldInfo myObjectFields o.GetType .GetFields BindingFlags.NonPublic BindingFlags.Public BindingFlags.Instance.. void Update MyObject o MyObject copyObject ... Type type o.GetType while type null UpdateForType type o copyObject type type.BaseType..
How do I get the member to which my custom attribute was applied? http://stackoverflow.com/questions/2168942/how-do-i-get-the-member-to-which-my-custom-attribute-was-applied passed in can do this public void Validate object o Type t o.GetType foreach PropertyInfo prop in t.GetProperties BindingFlags.Instance..
Is there a better alternative than this to 'switch on type'? http://stackoverflow.com/questions/298976/is-there-a-better-alternative-than-this-to-switch-on-type o .Skip else throw new ArgumentException Unexpected type o.GetType c# switch statement system.type share improve this question..
why Object.GetType() is not virtual? http://stackoverflow.com/questions/3253329/why-object-gettype-is-not-virtual Console.WriteLine object o myDerived Type is 0 o.GetType Console.WriteLine MyBaseClass b myDerived Type is 0 b.GetType..
How to check if an object is nullable? http://stackoverflow.com/questions/374651/how-to-check-if-an-object-is-nullable object obj object o object bc foreach var fieldInfo in o.GetType .GetFields bindingFlags obj object fieldInfo.GetValue o obj..
Getting 'basic' datatype rather than weird nullable one, via reflection in c# http://stackoverflow.com/questions/5174423/getting-basic-datatype-rather-than-weird-nullable-one-via-reflection-in-c-sha T IEnumerable T data object o data.First var properties o.GetType .GetProperties return properties.ToDictionary property property.Name..
How can I evaluate a C# expression dynamically? http://stackoverflow.com/questions/53844/how-can-i-evaluate-a-c-sharp-expression-dynamically object o a.CreateInstance CSCodeEvaler.CSCodeEvaler Type t o.GetType MethodInfo mi t.GetMethod EvalCode object s mi.Invoke o null..
How to use switch-case on a Type? [duplicate] http://stackoverflow.com/questions/7542793/how-to-use-switch-case-on-a-type ValidateProperties object o if o null var sourceType o.GetType var properties sourceType.GetProperties BindingFlags.Public..
How do I detect that an object is a generic collection, and what types it contains? http://stackoverflow.com/questions/755200/how-do-i-detect-that-an-object-is-a-generic-collection-and-what-types-it-contai static void Main object o new List int 1 2 3 4 5 Type t o.GetType Type lt GetListType t if lt null typeof Program .GetMethod..
Why is the C# compiler emitting a callvirt instruction for a GetType() method call? http://stackoverflow.com/questions/845657/why-is-the-c-sharp-compiler-emitting-a-callvirt-instruction-for-a-gettype-meth System class Program static void Main Object o new Object o.GetType L_0001 newobj instance void mscorlib System.Object .ctor L_0006..
getting type T from IEnumerable<T> http://stackoverflow.com/questions/906499/getting-type-t-from-ienumerablet IEnumerable Type GetGenericIEnumerables object o return o.GetType .GetInterfaces .Where t t.IsGenericType true t.GetGenericTypeDefinition..
C# get type of null object [duplicate] http://stackoverflow.com/questions/930147/c-sharp-get-type-of-null-object method private static string TypeNameLower object o return o.GetType .Name.ToLower to give me the lower case type name of the input..
|