dynamic-keyword

Is the dynamic keyword meant to be *only* used with dynamic languages?

I attended Code Camp 12 recently, and a speaker there said that the new dynamic keyword in C# 4.0 should only be used for interopping with dynamic languages. I think he also said that it is somewhat slow, compared to normal reflection (which itself is somewhat slow). But then I heard Scott Hanselman mention that the dynamic keyword "ma...

Dynamic Keyword and WPF hosted in MFC

We're looking to port a massive MFC app to WPF. In the interim, we want to host the new WPF controls in the legacy app until the entire app has been replicated. Hosting WPF controls in MFC is pretty straightforward, but one of the challenges we've had in the past is sharing data between the hosting MFC app and the hosted WPF control. ...

C# - Dynamic Keyword and Interface Implementations

I'm assuming this isn't possible but before digging further is there a way to do something like this: public void ProcessInterface(ISomeInterface obj) {} //... dynamic myDyn = GetDynamic<ISomeInterface>() ProcessInterface(myDyn); I've seen a post arguing for it but it sounds like it wasn't included. A little context: .Net assembl...

C# Using the Dynamic keyword to access properties via strings without reflection

I would like to write something similar to the following: // I will pass in a number of "properties" specified as strings that I want modified string[] properties = new [] { "AllowEdit", "AllowDelete" }; // Casting the component I'm using to a dynamic object of some sort ? dynamic d = myGridComponent; // Iterate over the strings an...

C# - Disable Dynamic Keyword

Is there any way to disable the use of the "dynamic" keyword in .net 4? I thought the Code Analysis feature of VS2010 might have a rule to fail the build if the dynamic keyword is used but I couldn't fine one. ...

dynamic, How to test if a property is available

Scenario is very simple somewhere in the code I have this dynamic myVariable = GetDataThatLooksVerySimilarButNotTheSame(); //how to do this? if (myVariable.MyProperty.Exists) //Do stuff So basically the question is how to check (avoiding exceptions) that a certain property is available in my dynamic variable. I could do GetType...

How can I create a sequence of numbered variables at run time?

Friends, I must create a series of ArrayLists, each containing objects of unknown origin, with each instance assigned to a separate local variable. So far, so good... But I also need each local variable's name to follow a very specific pattern: the name should begin with "oArr", followed by one or more digits reflecting that particular...

C# 4.0 Dynamic vs Expando... where do they fit ?

I am trying to learn all the new goodies that come with C# 4.0. I am failing to understand the differences between the Dynamic and Expando types. From the looks of things it seems like Dynamic is when you want to access variables etc from python scripts etc.Expando seems like a use ful tool when talking with COM/Office objects. I may be ...

Limitations of the dynamic type in C#

Could you give me some reasons for limitations of the dynamic type in C#? I read about them in "Pro C# 2010 and the .NET 4 platform". Here is an excerpt (if quoting books is illegal here, tell me and I will remove the excerpt): While a great many things can be defined using the dynamic keyword, there are some limitations regardin...

Javascript auto pick keywords from HTML

Given a body of HTML, is there any function out there someone has written that will automatically extract say the top 10 keywords that appear from a chunk of HTML, excluding any HTML tags (IE just plain text)? It should ignore common words like "and", "is" "but" etc but list the most frequent uncommon words. Example input: Mary had a ...