Linq 入门系列 [Group,Distinct,Union,Concat,Intersect,Except篇]

 ////////////////////////////
    
///以下是Group,Distinct,Union,Concat,Intersect,Except的例子和解释
    
/////////////////////////////

    class Program
    
{
        
DB

        
static void Main(string[] args)
        
{
            List
<Student> studentList = GetStudents();

            
//Group(studentList);

            
//Distinct(studentList);

            
//Union(studentList);

            
//Concat(studentList);

            Intersect(studentList);

            
//Except();
        }


        
Group,Distinct,Union,Concat,Intersect,Except

        
private static IEnumerable<Student> RevealChangeType<T>(T obj)
        
{
            IEnumerable
<Student> student = obj as IEnumerable<Student>;

            
return student;
        }

    }


    
sealed class Student
    
{
        
public int age;
        
public int Age
        
{
            
get return age; }
            
set { age = value; }
        }


        
private string name;
        
public string Name
        
{
            
get return name; }
            
set { name = value; }
        }


        
private string language;
        
public string Language
        
{
            
get return language; }
            
set { language = value; }
        }

    }
posted @ 2007-07-17 00:03  RicoRui  阅读(1380)  评论(0编辑  收藏  举报