SIGN UP MEMBER LOGIN:    
ARTICLE

Dynamic Programming in .NET 4.0

Posted by BALAMURUGAN ALAGUMALAI Articles | C# Language October 13, 2009
Dynamic programming is new addition to .NET 4.0 and C# 2010.
Reader Level:

C# 4.0 supports dynamic programming by introducing new dynamic typed objects. The type of these objects is resolved at run-time instead of at compile-time. The keyword tells the compiler that everything to do with the object, declared as dynamic, should be done dynamically at the run-time using Dynamic Language Runtime(DLR)


The main advantages of this dynamic programming are it provides more flexibility to developers.

Example:

dynamic num = Getnum();

dynamic str = GetString();

Console.WriteLine("Your number is " + num);

Console.WriteLine("Your string is " + str);

Console.Read();

 

private static string GetString()

{

    return "Welcome";

}

private static int Getnum()

{

    return 1;

}



Note: We use var keyword but the main different between the both is var resolved at compile time and dynamic resolved at runtime.

Login to add your contents and source code to this article
Article Extensions
Contents added by Mahesh Chand on Oct 14, 2009

If you need more details on dynamic types and dynamic programming, here are some more detailed references:

Here is a link on Dynamic Language Runtime:


Cheers!
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Become a Sponsor