Questions tagged [dynamic]
Dynamic is a widely used term that, in general, describes a decision made by the program at run-time rather than at compile time.
dynamic
27,392
questions
1190
votes
31
answers
1.1m
views
Deserialize JSON into C# dynamic object? [duplicate]
Is there a way to deserialize JSON content into a C# dynamic type? It would be nice to skip creating a bunch of classes in order to use the DataContractJsonSerializer.
579
votes
3
answers
296k
views
What's the difference between eval, exec, and compile?
I've been looking at dynamic evaluation of Python code, and come across the eval() and compile() functions, and the exec statement.
Can someone please explain the difference between eval and exec, ...
346
votes
7
answers
631k
views
How do you dynamically add elements to a ListView on Android?
Can anyone explain or suggest a tutorial to dynamically create a ListView in android?
Here are my requirements:
I should be able to dynamically add new elements by pressing a button.
Should be simple ...
334
votes
5
answers
224k
views
Are parameters in strings.xml possible? [duplicate]
I'm going to implement my strings with internationalization in my Android app. I have a problem with the grammar and the way sentences build in different languages.
For example:
"5 minutes ago&...
309
votes
20
answers
365k
views
Dynamic variable names in Bash
I am confused about a bash script.
I have the following code:
function grep_search() {
magic_way_to_define_magic_variable_$1=`ls | tail -1`
echo $magic_variable_$1
}
I want to be able to ...
296
votes
4
answers
168k
views
Dynamically adding properties to an ExpandoObject
I would like to dynamically add properties to a ExpandoObject at runtime. So for example to add a string property call NewProp I would like to write something like
var x = new ExpandoObject();
x....
279
votes
10
answers
186k
views
What is the 'dynamic' type in C# 4.0 used for?
C# 4.0 introduced a new type called 'dynamic'. It all sounds good, but what would a programmer use it for?
Is there a situation where it can save the day?
266
votes
16
answers
169k
views
Test if a property is available on a dynamic variable
My situation is very simple. Somewhere in my code I have this:
dynamic myVariable = GetDataThatLooksVerySimilarButNotTheSame();
//How to do this?
if (myVariable.MyProperty.Exists)
//Do stuff
So, ...
241
votes
2
answers
7k
views
Rendering Angular components in Handsontable Cells
In a project of mine, I try to display Angular Components (like an Autocomplete Dropdown Search) in a table. Because of the requirements I have (like multi-selecting different cells with ctrl+click) I ...
239
votes
15
answers
373k
views
Get value of c# dynamic property via string
I'd like to access the value of a dynamic c# property with a string:
dynamic d = new { value1 = "some", value2 = "random", value3 = "value" };
How can I get the value of d.value2 ("random") if I ...
238
votes
11
answers
253k
views
How to perform runtime type checking in Dart?
Dart specification states:
Reified type information reflects the types of objects at runtime and may always be queried by dynamic typechecking constructs (the
analogs of instanceOf, casts, ...
219
votes
11
answers
111k
views
How to implement a rule engine?
I have a db table that stores the following:
RuleID objectProperty ComparisonOperator TargetValue
1 age 'greater_than' 15
2 username 'equal' '...
215
votes
14
answers
96k
views
What's the difference between dynamic (C# 4) and var?
I had read a ton of articles about that new keyword that is shipping with C# v4, but I couldn't make out the difference between a "dynamic" and "var".
This article made me think about it, but I still ...
205
votes
12
answers
115k
views
How to detect if a property exists on an ExpandoObject?
In javascript you can detect if a property is defined by using the undefined keyword:
if( typeof data.myProperty == "undefined" ) ...
How would you do this in C# using the dynamic keyword with an ...
204
votes
7
answers
377k
views
How to create own dynamic type or dynamic object in C#?
There is, for example, the ViewBag property of ControllerBase class and we can dynamically get/set values and add any number of additional fields or properties to this object, which is cool. I want to ...