Using var : var « LINQ « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » LINQ » var 
22.1.1.Using var
using System;
using System.Collections.Generic;
using System.Diagnostics;

class MyPC {
    public Int32 Id get; set; }
    public Int64 Memory get; set; }
    public String Name get; set; }
}

class LanguageFeatures {
    static void Main(string[] args) {
        var processes = new List<MyPC>();
        foreach (var process in Process.GetProcesses()) {
            var data = new MyPC();
            data.Id = process.Id;
            data.Name = process.ProcessName;
            data.Memory = process.WorkingSet64;
            processes.Add(data);
        }
        Console.Write(processes);
    }
}
22.1.var
22.1.1.Using var
22.1.2.Anonymous Types
22.1.3.An Anonymous Type Assigned to a Variable Declared with the var Keyword
22.1.4.Instantiating and Initializing an Anonymous Type Using Object Initialization
22.1.5.An Example of Collection Initialization
22.1.6.Reflecting result from Linq
22.1.7.Explicit Range Variable
22.1.8.Automatic properties
22.1.9.Create struct for Collection with new syntax
22.1.10.Create and initialize the list of Simple type with new syntax
22.1.11.Filtering with OfType
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.