int text;
// если результат функции false, т.е. конвертирование прошло неудачно, показываем табличку с ошибкой
if(!int.TryParse(textBox1.Text, out text)) MessageBox.Show("Input value is invalid");
static class Extensions
{
public static IEnumerable<TSource> Remove<TSource>(this IEnumerable<TSource> collection, Predicate<TSource> predicate)
{
foreach(TSource item in collection)
{
if(!predicate?.Invoke(item)) yield return item;
}
}
}
class Program
{
public static void Main()
{
IEnumerable<Shape> shapes = new List<Shape> { new Square(), new Triangle(), new Circle(), new Circle() };
foreach(var shape in shapes.Remove(t => t.GetType() == typeof(Circle)))
{
Console.WriteLine(shape.GetType()); // Square, Triangle
}
}
}
public void DeleteCar(string carModel, string color, double speed, int yearOfIssue)
{
Car car = cars.FirstOrDefault(c => c.CarModel == carModel && c.Color == color && c.Speed == speed && c.YearOfIssue == yearOfIssue);
cars.Remove(car);
}
using System;
using System.Runtime.InteropServices;
class Example
{
// Use DllImport to import the Win32 MessageBox function.
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);
static void Main()
{
// Call the MessageBox function using platform invoke.
MessageBox(new IntPtr(0), "Hello World!", "Hello Dialog", 0);
}
}
var botusers = new List<string>();
using(var reader = findCommand.ExecuteReader())
{
while(reader.Read())
{
botusers.Add(reader.GetString(1));
}
}
var botusers = new List<string>();
using(var reader = await findCommand.ExecuteReaderAsync())
{
while(await reader.ReadAsync())
{
botusers.Add(reader.GetString(1));
}
}