static void Main() { var stations = new StationList(); var stationOne = new RadioStation(98.1); stations.Add(stationOne); var stationTwo = new RadioStation(89.9); stations.Add(stationTwo); var stationThree = new RadioStation(106.1); stations.Add(stationThree); foreach (var station in stations) { Console.WriteLine($"Stations: {station.Frequency}"); } // ReSharper disable once CompareOfFloatsByEqualityOperator var q = stations.FirstOrDefault(x => x.Frequency == 98.1); Console.WriteLine($"First station where frequency is equal to 98.1: {q?.Frequency}"); }
//Provide a way to access the elements of an aggregate object swquentially //without exposing its underlying representation. static void Main(string[] _) { var stations = new StationList(); stations.AddStation(new RadioStation(11)); stations.AddStation(new RadioStation(34)); var ferequency11 = stations.First(s => s.GetFrequency() == 11); Console.WriteLine(ferequency11.GetFrequency()); Console.ReadKey(); }
public static void Main(string[] args) { var stations = new StationList(); stations.Add(new RadioStation(77)); stations.Add(new RadioStation(49)); var frecancy77 = stations.First(x => x.GetFrencancy() == 77); Console.WriteLine("The Stations is:" + frecancy77.GetFrencancy()); Console.ReadKey(); }