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.

Programs that perform some common tasks based on program inputs in contrast with programs that predetermine the task beforehand. Dynamic is often used to mean:

  • The dynamic keyword
  • using JavaScript to manipulate web pages in the browser.
  • have features that allow the of a variable to be bound at run-time.
  • Program generated content, especially content in contrast with web pages created by a person and stored on disk, ready to serve.
27209 questions
59
votes
8 answers

how to create an animated gif in .net

Does anyone know how to create an animated gif using c#? Ideally I would have some control over the color reduction used. Is using imagemagick (as an external started process) the best choice?
The dude
58
votes
3 answers

Is the use of dynamic considered a bad practice?

In C#, someone can do: MyClass myInstance = new MyClass(); dynamic mydynamicInstance = myInstance; And then, invoke a method, like: //This method takes a MyClass argument and does something. Caller.InvokeMethod(myDynamicInstance); Now, this…
Nick Louloudakis
  • 5,856
  • 4
  • 41
  • 54
58
votes
2 answers

Why is C# dynamic type static?

While reading and exploring the dynamic keyword I found following line on [MSDN] (in Using Type dynamic (C# Programming Guide)): The type is a static type, but an object of type dynamic bypasses static type checking. In most cases, it functions…
slash shogdhe
  • 3,943
  • 6
  • 27
  • 46
58
votes
4 answers

How do I express a void method call as the result of DynamicMetaObject.BindInvokeMember?

I'm trying to give a short example of IDynamicMetaObjectProvider for the second edition of C# in Depth, and I'm running into issues. I want to be able to express a void call, and I'm failing. I'm sure it's possible, because if I dynamically call a…
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
57
votes
10 answers

How to dynamically allocate memory space for a string and get that string from user?

I want to read input from user using C program. I don't want to use array like, char names[50]; because if the user gives string of length 10, then the remaining spaces are wasted. If I use character pointer like, char *names; then I need to…
Dinesh
  • 16,014
  • 23
  • 80
  • 122
57
votes
2 answers

Why can't I index into an ExpandoObject?

Something caught me by surprise when looking into C# dynamics today (I've never used them much, but lately I've been experimenting with the Nancy web framework). I found that I couldn't do this: dynamic expando = new ExpandoObject(); expando.name =…
Richiban
  • 5,569
  • 3
  • 30
  • 42
57
votes
1 answer

How to dynamically get a property by name from a C# ExpandoObject?

I have an ExpandoObject and want to make a getter for it that will return a property by name at runtime, where the name is specified in a string instead of hardcoded. For example, I CAN do this: account.features.isEmailEnabled; and that will return…
user2838966
  • 653
  • 1
  • 5
  • 11
57
votes
6 answers

What is the difference between dynamic programming and greedy approach?

What is the main difference between dynamic programming and greedy approach in terms of usage? As far as I understood, the greedy approach sometimes gives an optimal solution; in other cases, the dynamic programming approach gives an optimal…
Riding Cave
  • 1,029
  • 1
  • 15
  • 32
56
votes
15 answers

Modifying CSS class property values on the fly with JavaScript / jQuery

I've run into a unique situation that I have so far been unable to find a solution for: dynamically assigning a value to a CSS style. I know how to use jQuery to assign width, height, etc. to an element, but what I'm trying to do is actually change…
JPN
  • 561
  • 1
  • 4
  • 3
56
votes
8 answers

Is there a reason to call delete in C++ when a program is exiting anyway?

In my C++ main function, for example, if I had a pointer to a variable which uses heap memory (as opposed to stack memory) - is this automatically deallocated after my application exits? I would assume so. Even so, is it good practice to always…
Nick Bolton
  • 38,276
  • 70
  • 174
  • 242
56
votes
5 answers

dynamic vs object type

I have used the dynamic and the object type interchangeably. Is there any difference between these two types? Is there any performance implications of using one over the other? Which one of these is more flexible?
Luke101
  • 63,072
  • 85
  • 231
  • 359
56
votes
11 answers

Getting static property from a class with dynamic class name in PHP

I have this: one string variable which holds the class name ($classname) one string variable with holds the property name ($propertyname) I want to get that property from that class, the problem is, the property is static and I don't know how to…
treznik
  • 7,955
  • 13
  • 47
  • 59
55
votes
3 answers

Method to dynamically load java class files

What would be a good way to dynamically load java class files so that a program compiled into a jar can read all the class files in a directory and use them, and how can one write the files so that they have the necessary package name in relation to…
MirroredFate
  • 12,396
  • 14
  • 68
  • 100
55
votes
2 answers

Lots of first chance Microsoft.CSharp.RuntimeBinderExceptions thrown when dealing with dynamics

I've got a standard 'dynamic dictionary' type class in C# - class Bucket : DynamicObject { readonly Dictionary m_dict = new Dictionary(); public override bool TrySetMember(SetMemberBinder binder, object…
Orion Edwards
  • 121,657
  • 64
  • 239
  • 328
54
votes
3 answers

Swift 3 - dynamic vs @objc

What's the difference between marking a method as @objc vs dynamic, when would you do one vs the other? Below is Apple's definition for dynamic. dynamic Apply this modifier to any member of a class that can be represented by Objective-C. When you…
Boon
  • 40,656
  • 60
  • 209
  • 315