¡@

Home 

c# Programming Glossary: obj.gettype

C# generic list <T> how to get the type of T? [duplicate]

http://stackoverflow.com/questions/1043755/c-sharp-generic-list-t-how-to-get-the-type-of-t

Type GetGenericType object obj if obj null Type t obj.GetType if t.IsGenericType Type at t.GetGenericArguments t at.First..

Parse JSON in C#

http://stackoverflow.com/questions/1212344/parse-json-in-c-sharp

serialiser new DataContractJsonSerializer obj.GetType ms.Close return obj Deserialise from JSON Serializable public.. serializer new DataContractJsonSerializer obj.GetType obj T serializer.ReadObject ms Your missing line return obj.. serializer new DataContractJsonSerializer obj.GetType using MemoryStream ms new MemoryStream serializer.WriteObject..

General purpose FromEvent method

http://stackoverflow.com/questions/12865848/general-purpose-fromevent-method

var tcs new TaskCompletionSource object var eventInfo obj.GetType .GetEvent eventName Type eventDelegate eventInfo.EventHandlerType.. new TaskCompletionSourceHolder tcs EventInfo eventInfo obj.GetType .GetEvent eventName Type eventDelegateType eventInfo.EventHandlerType..

Distinct not working with LINQ to Objects

http://stackoverflow.com/questions/1365748/distinct-not-working-with-linq-to-objects

set public override bool Equals object obj return true if obj.GetType typeof Author return false else return Author obj .FirstName..

Writing a CompareTo DataAnnotation Attribute

http://stackoverflow.com/questions/1607832/writing-a-compareto-dataannotation-attribute

obj string propertyName if obj null return null var type obj.GetType var propertyInfo type.GetProperty propertyName if propertyInfo..

Why XML-Serializable class need a parameterless constructor

http://stackoverflow.com/questions/267724/why-xml-serializable-class-need-a-parameterless-constructor

object obj XmlSerializer serializer new XmlSerializer obj.GetType using StringWriter writer new StringWriter serializer.Serialize..

Anonymous Types - Are there any distingushing characteristics?

http://stackoverflow.com/questions/315146/anonymous-types-are-there-any-distingushing-characteristics

static T Get T this IAnonymous obj string prop return T obj.GetType .GetProperty prop .GetValue obj null ... And then used like.....

Serializing anonymous delegates in C#

http://stackoverflow.com/questions/321827/serializing-anonymous-delegates-in-c-sharp

info StreamingContext context foreach FieldInfo f in obj.GetType .GetFields BindingFlags.Instance BindingFlags.Public BindingFlags.NonPublic.. ISurrogateSelector selector foreach FieldInfo f in obj.GetType .GetFields BindingFlags.Instance BindingFlags.Public BindingFlags.NonPublic..

.Net - Reflection set object property

http://stackoverflow.com/questions/619767/net-reflection-set-object-property

using System.Reflection MyObject obj new MyObject obj.GetType .InvokeMember Name BindingFlags.Instance BindingFlags.Public.. MyObject obj new MyObject PropertyInfo prop obj.GetType .GetProperty Name BindingFlags.Public BindingFlags.Instance..

How to get the list of properties of a class?

http://stackoverflow.com/questions/737151/how-to-get-the-list-of-properties-of-a-class

share improve this question Reflection for an instance obj.GetType .GetProperties for a type typeof Foo .GetProperties for example..

C# - How to access internal class from external assembly

http://stackoverflow.com/questions/920844/c-sharp-how-to-access-internal-class-from-external-assembly

get this via reflection object obj ... string value string obj.GetType .GetField test .GetValue obj If it is actually a property not.. it is actually a property not a field string value string obj.GetType .GetProperty test .GetValue obj null If it is non public you'll..

Get the item doubleclick event of listview

http://stackoverflow.com/questions/929179/get-the-item-doubleclick-event-of-listview

e.OriginalSource while obj null obj myListView if obj.GetType typeof ListViewItem Do something here MessageBox.Show A ListViewItem..

C# get type of null object [duplicate]

http://stackoverflow.com/questions/930147/c-sharp-get-type-of-null-object

string TypeNameLower object obj if obj null return obj.GetType .Name.ToLower else return null string s null TypeNameLower s..

Tuples( or arrays ) as Dictionary keys in C#

http://stackoverflow.com/questions/955982/tuples-or-arrays-as-dictionary-keys-in-c-sharp

override bool Equals object obj if obj null GetType obj.GetType return false return Equals Tuple T U W obj public bool Equals..