static void Main(string[] args) { var buffer = new CircularBuffer(capacity: 3); while (true) { var value = 0.0; var input = Console.ReadLine(); if (double.TryParse(input, out value)) { buffer.Write(value); continue; } break; } var sum = 0.0; Console.WriteLine("Buffer: "); while (!buffer.IsEmpty) { sum += buffer.Read(); } Console.WriteLine(sum); }
static void Main(string[] args) { CircularBuffer buffer = new CircularBuffer(capacity: 3); while (true) { string input = Console.ReadLine(); byte value; if (byte.TryParse(input, out value)) { buffer.Write(value); } else { break; } } Console.Write("Buffer: "); while (!buffer.IsEmpty) { byte a = buffer.Read(); Console.Write(a + " "); } Console.ReadKey(); }
private static void ProcessInput(CircularBuffer <double> buffer) { while (true) { var value = 0.0; var input = Console.ReadLine(); if (double.TryParse(input, out value)) { buffer.Write(value); continue; } break; } }