Linq test

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
					
public class Program
{
    static event EventHandler MyEvent;

    public static void Main()
    {
        List<Status> statuses = new List<Status>();
        Status st = new Status();
		st.StatusID = 1;
		st.StatusDescr = "TEST DESC";
		statuses.Add(st);	
		
		int id = 1;
		var result = statuses.FirstOrDefault(x => x.StatusID == id);
		
		string test = "";
		
		if(result != null)
           test = result.StatusDescr;
		
		Console.WriteLine(test);
		
    }
	
	public class Status
	{
		public int StatusID { get; set; }
		public string StatusDescr { get; set; }
		public string StatusType { get; set; }
	}

}
;