Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Jon Limjap<br />Microsoft Most Valuable Professional for Visual C#<br />Senior Application Developer, FBM e-Services<br />...
?<br />Do you<br />use C#<br />
?<br />Is C#...<br />static<br />dynamic<br />
static<br />dynamic<br />C# 4.0<br />
Microsoft<br />.NET<br />Dynamic Language Runtime<br />
Why dynamic?<br />
Expressiveness<br />Tell me what to do…<br />…not how to do it<br />
Duck Typing<br />If it quacks, it’s a duck!<br />
Object Runtime Modification<br />Object types can be modified on runtime<br />
Dynamic at compile time<br />dynamic myObj = "blah";<br />System.String at run time<br />
dynamic myObj = "blah";<br />Console.WriteLine(myObj.Contains("lah"));Console.WriteLine(myObj.IndexOf("x"));Console.WriteL...
Requires System.Dynamic<br />dynamic mrFantastic = new ExpandoObject();mrFantastic.Name = "Reed Richards";mrFantastic.Birt...
mrFantastic.SayMyName = new Action(<br />() => Console.WriteLine(mrFantastic.Name));mrFantastic.GetAge = new Func<int>(<br...
jonlimjap@gmail.com<br />http://twitter.com/LaTtEX<br />http://dotnet.kapenilattex.com<br />
Próxima SlideShare
Cargando en…5
×

Dynamics & Object Runtime Composition with C# 4.0

1.728 visualizaciones

Publicado el

A discussion of the new language features of C# 4.0, emphasizing on the dynamic programming capabilities of the language and its ability to define objects at runtime

Publicado en: Tecnología
  • Sé el primero en comentar

Dynamics & Object Runtime Composition with C# 4.0

  1. 1. Jon Limjap<br />Microsoft Most Valuable Professional for Visual C#<br />Senior Application Developer, FBM e-Services<br />Dynamics & Object Runtime Composition with C# 4.0<br />
  2. 2. ?<br />Do you<br />use C#<br />
  3. 3. ?<br />Is C#...<br />static<br />dynamic<br />
  4. 4. static<br />dynamic<br />C# 4.0<br />
  5. 5. Microsoft<br />.NET<br />Dynamic Language Runtime<br />
  6. 6. Why dynamic?<br />
  7. 7. Expressiveness<br />Tell me what to do…<br />…not how to do it<br />
  8. 8. Duck Typing<br />If it quacks, it’s a duck!<br />
  9. 9. Object Runtime Modification<br />Object types can be modified on runtime<br />
  10. 10. Dynamic at compile time<br />dynamic myObj = "blah";<br />System.String at run time<br />
  11. 11. dynamic myObj = "blah";<br />Console.WriteLine(myObj.Contains("lah"));Console.WriteLine(myObj.IndexOf("x"));Console.WriteLine(myObj.GetType());myObj = new List<int>();Console.WriteLine(myObj.Count);Console.WriteLine(myObj.GetType());<br />Change of type here<br />But no compiler errors!<br />Method signature doesn’t match initial type<br />
  12. 12. Requires System.Dynamic<br />dynamic mrFantastic = new ExpandoObject();mrFantastic.Name = "Reed Richards";mrFantastic.BirthDate = <br />new DateTime(year: 1961, month: 12, day: 2);Console.WriteLine(mrFantastic.Name);Console.WriteLine(mrFantastic.BirthDate);<br />Properties can be added during runtime<br />
  13. 13. mrFantastic.SayMyName = new Action(<br />() => Console.WriteLine(mrFantastic.Name));mrFantastic.GetAge = new Func<int>(<br />() => Convert.ToInt32(<br />(DateTime.Now - mrFantastic.BirthDate).Days <br />/ 365.25));mrFantastic.SayMyName();Console.WriteLine(mrFantastic.GetAge());<br />Methods could be added using Action<T> & Func<T><br />
  14. 14. jonlimjap@gmail.com<br />http://twitter.com/LaTtEX<br />http://dotnet.kapenilattex.com<br />

×