diff options
author | Miguel de Icaza <miguel@gnome.org> | 2008-09-05 00:28:10 +0400 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2008-09-05 00:28:10 +0400 |
commit | 54cd9363a6532b96e66e26de33f0d4f9f935a4d1 (patch) | |
tree | bb9daaea49b587dea33d7d0657dd5312deda7751 /man/csharp.1 | |
parent | 64aaf71fca7a8f762f2bcb77328a2f4a65223e93 (diff) |
Document new features; Fix typos
svn path=/trunk/mono/; revision=112327
Diffstat (limited to 'man/csharp.1')
-rw-r--r-- | man/csharp.1 | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/man/csharp.1 b/man/csharp.1 index 6466bfe0600..76df111cb8e 100644 --- a/man/csharp.1 +++ b/man/csharp.1 @@ -88,8 +88,9 @@ csharp> .fi .PP A few datatypes are handled specially by the C# interactive shell like -arrays, System.Collections.Hashtable and are rendered specially -instead of just using ToString (): +arrays, System.Collections.Hashtable, objects that implement +System.Collections.IEnumerable and IDictionary and are rendered +specially instead of just using ToString (): .PP .nf csharp> var pages = new Hashtable () { @@ -99,7 +100,6 @@ csharp> pages; {{ "Mono", "http://www.mono-project.com/" }, { "Linux", "http://kernel.org" }} .fi .PP -.PP It is possible to use LINQ directly in the C# interactive shell since the System.Linq namespace has been imported at startup. The following sample gets a list of all the files that have not been @@ -119,14 +119,23 @@ You can of course print the results in a single statement as well: .nf csharp> using System.IO; csharp> var last_week = DateTime.Now - TimeSpan.FromDays (7); -csharp> foreach (var old from f in Directory.GetFiles ("/tmp") +csharp> from f in Directory.GetFiles ("/tmp") > let fi = new FileInfo (f) - > where fi.LastAccessTime < LastWeek select f) - > Console.WriteLine (old); + > where fi.LastAccessTime < last_week select f; [...] csharp> .fi .PP +LINQ and its functional foundation produce on-demand code for +IEnumerable return values. For instance, the return value from a +using `from' is an IEnumerable that is evaluated on demand. The +automatic rendering of IEnumerables on the command line will trigger +the IEnumerable pipeline to execute at that point instead of having +its execution delayed until a later point. +.PP +If you want to avoid having the IEnumerable rendered at this point, +simply assign the value to a variable. +.PP Unlike compiled C#, the type of a variable can be changed if a new declaration is entered, for example: .PP |