Alexis Smirnov
Thinking about software




Saturday, November 09, 2002
 

Gotdotnet More detais about future C# features such as Generics, Anonymous Methods, Partial Types and simplified Iterators. (via SBC's weblog). Pretty exciting stuff.

Here are quick examples from the presentation by Anders Hejlsberg:

  • Generics, a form of C++ templates that makes reusing existing code easier
    List<int> intList = new List<int>();
    intList.Add("one"); // Generates compile-time error
  • Iterators, a construct that makes traversing collections of data significantly faster and easier
    public class List
    {
        internal object[] elements;
        internal int count;
        public object foreach() {
            for( int i=0; i<count; i++) yield elements[i];
    }
  • Anonymous methods, an easier way to perform simple tasks using delegates
    public class Bank
    {
        ArrayList accounts;
        ArrayList GetLargeAccounts( int minBalance) {
           return accounts.Select( new Filter(a) { return ((Account)a).Balance >= minBalance;} );
        }
    }
  • Partial types, a means for programmers to split code across multiple files
    public partial class Customer
    {
        private string name;
    }

    public partial class Customer
    {
        public void DoSomething() { ... }
    }

  •     


    Subscribe to "Alexis Smirnov" in Radio UserLand. Click to see the XML version of this web page. Click here to send an email to the editor of this weblog.
    Site Statistics
    © Copyright 2003 Alexis Smirnov.


    Last update: 5/6/2003; 5:42:47 PM.

    November 2002
    Sun Mon Tue Wed Thu Fri Sat
              1 2
    3 4 5 6 7 8 9
    10 11 12 13 14 15 16
    17 18 19 20 21 22 23
    24 25 26 27 28 29 30
    Oct   Dec

    Aug 2002