2007-08-06から1日間の記事一覧

C# 3.0 雑感

おもしろい! 嗚呼・・・一気にC#で埋まってしまったマイブログ

C# 3.0 - LINQ to Objects 複数フィールド抽出

C#

複数フィールドを取得する場合は、selectに匿名型を指定します using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Program { static void Main(string[] args) { var persons = new[] { ne…

C# 3.0 - LINQ to Objects

C#

言語統合クエリ 最も大きな拡張 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Program { static void Main(string[] args) { var persons = new[] { new { Age = 22, Name = "Akira" …

C# 3.0 - ラムダ式

C#

賛否両論なラムダ式 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Person { public int Age { get; set; } public string Name { get; set; } } class Program { static void Main(st…

C# 3.0 - 拡張メソッド

C#

C# 3.0で唯一いらないもの既存のクラスにメソッドを追加できる using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { // intにHogeメソッドを追加 public static class IntExtention { public stati…

C# 3.0 - 匿名型配列

C#

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Program { static void Main(string[] args) { var persons = new[] { new { Age = 22, Name = "Akira" }, new { Age = 38, Name = "Bob…

C# 3.0 - 匿名型

C#

指定したプロパティを持つクラスを匿名で作成する using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Program { static void Main(string[] args) { var person = new { Age = 22, Name = …

C# 3.0 - 暗黙に型付けられた型(var)

C#

型推論によってコンパイル時に決定される型 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Program { static void Main(string[] args) { var n = 3; int value = n; var ar = new List<int></int>…

C# 3.0 - オブジェクト初期化子

C#

プロパティを指定した初期化ができる using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Hoge { public int Age { get; set; } public string Name { get; set; } public void Disp() { Co…

C# 3.0 - 自動プロパティ

C#

流行りに乗ってたまにはC#でもやりましょう プロパティが簡単に書けるようになる using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Hoge { public int Age { get; set; } public string N…