January 12, 2010 by Christoff Truter C#
The 1st of Jan 2010 I installed Visual C# 2010 Express, quite appropriate date
don't you think? (Delayed thanks to my lack of bandwidth among other
things, but don't let me get started on that one, sigh)
I know at this point I am a few million years behind writing on this subject, but hey,
better late than never.
Nevertheless, I've been having some fun playing around and reading up on all the
wonderous new features for a while now - new to C# at least.
The focus of this release (version 4.0), is "Dynamic Programming", which is somewhat code word
for "We're compromising to fit/interact with other Tom, Dick & Harry languages". (You guys know
who you are)
The new features can be broken up in four groups:
dynamic a = "Dude"; // I am string a = 10; // No, wait I am an int a = DateTime.Now; // Oh, now I am a date
// Notice the optional parameters static void test(Int32 i, String s1 = "Test1", String s2 = "Test2") { Console.WriteLine(i); Console.WriteLine(s1); Console.WriteLine(s2); } static void Main(string[] args) { // Excluding optional parameters test(1); // Notice s2, a named parameter test(1, s2: "Test4"); }
object missing = Missing.Value; object newfilename = "a.docx"; document.SaveAs(ref newfilename, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
document.SaveAs("a.docx");
using System; using System.Collections.Generic; using System.Linq; using System.Text; class a { } class b : a { } delegate T covariance<out T>(); delegate void contravariance<in T>(T value); class Program { static void Main(string[] args) { covariance<b> _b = () => new b(); covariance<a> _a = _b; contravariance<a> _a1 = (param) => { Console.WriteLine(param); }; contravariance<b> _b1 = _a1; } }
January 19, 2015