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
54
votes
4 answers

Dynamic class in Angular.js

I want to dynamically add a css class to an
  • element I am looping over. The loop is like this:
  • {{todo.title}}

    {{todo.description}}

  • In…
    mpaepper
    • 3,952
    • 3
    • 21
    • 28
    53
    votes
    1 answer

    Why do I get this compile error trying to call a base constructor/method that takes a dynamic argument?

    While refactoring some code, I came across this strange compile error: The constructor call needs to be dynamically dispatched, but cannot be because it is part of a constructor initializer. Consider casting the dynamic arguments. It seems to…
    Danny Tuppeny
    • 40,147
    • 24
    • 151
    • 275
    53
    votes
    4 answers

    Set Attribute Dynamically of Ruby Object

    How can I set an object attribute dynamically in Ruby e.g. def set_property(obj, prop_name, prop_value) #need to do something like > obj.prop_name = prop_value #we can use eval but I'll prefer a faster/cleaner alternative: eval…
    neebz
    • 11,465
    • 7
    • 47
    • 64
    52
    votes
    6 answers

    Dynamically create an object of

    I have a table in my database that I use to manage relationships across my application. it's pretty basic in it's nature - parentType,parentId, childType, childId... all as ints. I've done this setup before, but I did it with a switch/case setup…
    thaBadDawg
    • 5,160
    • 6
    • 35
    • 44
    52
    votes
    3 answers

    How can I insert a script into HTML head dynamically using JavaScript?

    How can I insert a script into HTML head dynamically using JavaScript?
    Wasim A.
    • 9,660
    • 22
    • 90
    • 120
    52
    votes
    4 answers

    How to set a property of a C# 4 dynamic object when you have the name in another variable

    I'm looking for a way to modify properties on a dynamic C# 4.0 object with the name of the property known only at runtime. Is there a way to do something like (ExpandoObject is just used as an example, this could be any class that implements…
    Kieran Benton
    • 8,739
    • 12
    • 53
    • 77
    52
    votes
    6 answers

    Casting Dynamic and var to Object in C#

    Consider these functions: static void Take(object o) { Console.WriteLine("Received an object"); } static void Take(int i) { Console.WriteLine("Received an integer"); } When I call the Take function this way: var a = (object)2; Take(a); I…
    user1968030
    50
    votes
    3 answers

    C# 4 "dynamic" in expression trees

    I'm trying to figure out how to put all the pieces together, and would appreciate a concrete source code sample for a simple case to start with. Consider the following C# code: Func f = (x, y) => x + y; I can produce an equivalent…
    Pavel Minaev
    • 99,783
    • 25
    • 219
    • 289
    50
    votes
    1 answer

    Difference between Strong vs Static Typing AND Weak vs Dynamic Typing

    From what I understand, dynamic typing is the same as weak typing and strong typing is the same as static typing, but I'm not sure I'm correct.
    Airon Zagarella
    • 707
    • 2
    • 11
    • 17
    49
    votes
    5 answers

    Dynamic loading of images in WPF

    I have a strange issue with WPF, I was loading images from the disk at runtime and adding them to a StackView container. However, the images were not displayed. After some debugging I found the trick, but it really doesn't make any sense. I've…
    sindre j
    • 4,404
    • 5
    • 31
    • 32
    49
    votes
    12 answers

    Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute'

    I'm trying to run a .NET MVC application on my local computer that I got from GitHub. When I hit run on Visual Studio, everything complies and a new browser window opens with the error: CS1980: Cannot define a class or member that utilizes…
    Alejandro Lozdziejski
    • 1,063
    • 4
    • 12
    • 30
    49
    votes
    5 answers

    Load package dynamically

    Is it possible to load a specific package during runtime? I want to have a kind of plugins where each one has the same functions than the others but with different behaviour, and depending on the configuration file, load one or other.
    Pepeluis
    • 931
    • 2
    • 10
    • 18
    49
    votes
    4 answers

    Is something wrong with the dynamic keyword in C# 4.0?

    There is some strange behavior with the C# 4.0 dynamic usage: using System; class Program { public void Baz() { Console.WriteLine("Baz1"); } static void CallBaz(dynamic x) { x.Baz(); } static void Main(string[] args) { dynamic a = new…
    controlflow
    • 6,667
    • 1
    • 31
    • 55
    49
    votes
    2 answers

    How do you dynamically compile and load external java classes?

    (This question is similar to many questions I have seen but most are not specific enough for what I am doing) Background: The purpose of my program is to make it easy for people who use my program to make custom "plugins" so to speak, then compile…
    Shadowtrot
    • 710
    • 1
    • 7
    • 13
    48
    votes
    3 answers

    "cannot implement interface member" error when interface and concrete are in different projects

    This compiles: public interface IMyInterface { event Action OnSomeEvent; } class MyInterface : IMyInterface { public event Action OnSomeEvent; } But when i separate the interface and the implementation to different…
    seldary
    • 6,186
    • 4
    • 40
    • 55