000173. C# введение в Linq
cs
public class Car {
public string Name { get; set; }
public int Speed { get; set; }
public Car( string Name, int Speed ) {
this.Name = Name;
this.Speed = Speed;
}
}cs
using System;
using System.Collections.Generic;
using System.Linq; // Подключаем пространство имён
namespace ConsoleApplication1 {
class Program {
static void Main( string[] args ) {
List<Car> myCars = new List<Car>();
var rnd = new Random();
var count = rnd.Next( 5, 10 );
for( int i = 0; i < count; i++ )
myCars.Add( new Car( "Car " + i, rnd.Next( 30, 120 ) ) );
Console.ReadKey();
}
}
public class Car {
public string Name { get; set; }
public int Speed { get; set; }
public Car( string Name, int Speed ) {
this.Name = Name;
this.Speed = Speed;
}
}
}Last updated