Results 1 to 3 of 3

Thread: C# 4.0 Dynamic

  1. #1
    Join Date
    May 2008
    Posts
    3,971

    C# 4.0 Dynamic

    One of the core features introduced in C# 4.0 is called Dynamic Lookup which allows a unified approach to invoking things dynamically. C# 3.0 was all about Language Integrated Query (LINQ) and C# 4.0 is all about dynamic programming. C# 4.0 brings some of flexibility and declarative style of programming to C#. C# 4.0 features a new dynamic keyword that allows you to mix in a bit of late-bound code in the midst of your otherwise statically typed code. It is used as a data type in much the same way the var keyword is used. The biggest reason is that it allows a C# program to use dynamic dispatch to more naturally create objects coming from a dynamic language.

    As an example, suppose you have a method like this:
    Code:
    public dynamic myMethod()
    {
        // Get your work done here...
    }
    and you call it as:

    Code:
    dynamic callMethod = myMethod();
    callMethod.Do("Your Job");
    The C# 4.0 compiler allows you to call a method with any name and any arguments because callMethod is declared as "dynamic".

  2. #2
    Join Date
    May 2008
    Posts
    271

    Re: C# 4.0 Dynamic

    Does that means C# 4.0 is lacking the statically typed language? Because if you don't mention the datatype of a variable, there should be an error saying data type is missing. If C# 4.0 gives us so much of flexibility then no one will mention any data type and will simply use "dynamic" keyword.

  3. #3
    Join Date
    May 2008
    Posts
    3,971

    Re: C# 4.0 Dynamic

    Well, no. The basic idea behind this is to provide flexibility to write C# code which talks to objects (or APIs). The "dynamic" operand differs compile-time declaration with run-time. At run-time the "dynamic" is replaced with the actual datatype. So if a variable is assigned a value of "1", the datatype will automatically be converted to "System.Int32".

Similar Threads

  1. What are the Dynamic Signatures?
    By Mei-Xiu in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 11:01 PM
  2. I need some details about Dynamic DNS
    By Bansi_WADIA in forum Technology & Internet
    Replies: 4
    Last Post: 16-01-2010, 05:00 AM
  3. Dynamic Overclocking
    By wazzeledozzle in forum Overclocking & Computer Modification
    Replies: 6
    Last Post: 06-12-2008, 05:55 PM
  4. How can I have a dynamic IP address
    By Spectacle in forum Networking & Security
    Replies: 4
    Last Post: 21-10-2008, 06:50 PM
  5. Help me redirecting dynamic IP
    By Maximus() in forum Networking & Security
    Replies: 3
    Last Post: 04-08-2008, 03:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,510,945.53119 seconds with 16 queries