c# - with dynamic, awkward reflection no more? -


Introduces C # 4.0 dynamic keywords, which will appear in run-time

Does this mean we need a weird reflection now? If it does, can you show an example of it?

We still will reflection - Reflection-based dispatcher using 'dynamic' against regular CLR objects

So - we will still reflect, but it will be easy to do.

Here is an example:

  // 'dynamic' via dynamic dx = GetSomeCLRObject (); Dx.DoSomething (); Dx.SomeMember = 2; // y reflection object x = getSomeCLRObject (); Type xt = x.GetType (); MemberInfo DoSomethingMethod = xt.GetMethod ("DoSomething"); DoSomethingMethod.Invoke (x, blank); Property Info SomemplateProperty = xt.GetProperty ("Some Member"); SomeMelpPropertySet Values ​​(X, 2);  

I do not know about you, but I like the pre =)

In both of these cases, I have not checked any compiled periodically, no No Intelligence, no IDE support - but former case is more expressive than later words.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -