using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Runtime.CompilerServices; namespace PV178 { class Person { public int Age { get; set; } public string Name { get; set; } } class Program { private const int SENIORAGE = 60; static void Main(string[] args) { int[] j = {2,4,6,8,10,11}; int k = 3; Program p = new Program(); System.Console.WriteLine(p.SelectElement(j,k)); List people = new List(); Person pe = new Person(); pe.Age = 100; pe.Name = "Josef Stolety"; people.Add(pe); pe = new Person(); pe.Age = 80; pe.Name = "Jan Osmdesatnik"; people.Add(pe); pe = new Person(); pe.Age = 20; pe.Name = "Jiri Mlady"; people.Add(pe); Console.WriteLine(people.Count()); Console.WriteLine(p.SeniorNames(people).Count()); Console.ReadKey(); } [MethodImpl(MethodImplOptions.Synchronized)] public int[] OddElements(int[] elements) { return (int[]) elements.Where(x => x % 2 == 1); } private IEnumerable SeniorNames(IEnumerable people) { var query = from p in people where p.Age > SENIORAGE select p.Name; return query; } public unsafe int SelectElement(int[] array, int offset) { fixed (int *ptr = array) { return *(ptr + offset); } } } }