public class Section
{
public string type { get; set; }
public string group { get; set; }
public int count { get; set; }
public string name { get; set; }
public string displaytype { get; set; }
public List<object> data { get; set; }
}
public class RootObject
{
public string xmlns { get; set; }
public string status { get; set; }
public string version { get; set; }
public int webplayer { get; set; }
public string responsetype { get; set; }
public List<Section> sections { get; set; }
}
class Program
{
static void Main(string[] args)
{
string rawJson = File.ReadAllText("data.json"); // for example
OrderCollection orders = JsonConvert.DeserializeObject<OrderCollection>(rawJson);
foreach (var item in orders.Orders.GroupBy(x => x.Id))
{
Console.WriteLine($"Order id: {item.Key}, sum: {item.Sum(x => x.Sum)}");
}
}
}
class OrderCollection
{
public List<Order> Orders { get; set; }
}
class Order
{
public int Id { get; set; }
public string Sku { get; set; }
public int Sum { get; set; }
}
Console.WriteLine((100000000).ToString("N0")); // output: 100 000 000
Console.WriteLine(string.Format("{0:### ### ###}", 100000000)); // output: 100 000 000
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "check.txt");
using (var db = new WS2016Entities())
{
var emails = db.User.Select(date => new { Email = date.Email }).ToList();
emails.ForEach(x => Console.WriteLine(x.Email));
}
public partial class Form1 : Form
{
List<Label> Labels { get; }
public Form1()
{
InitializeComponent();
//1 Вариант: Коллекция со всеми нужными лейблами.
//Обратите внимание, что используются сами КОНТРОЛЫ, а НЕ их ИМЕНА.
Labels = new List<Label> { label1, label2, label3, label4, label5, label6, label7, label8, label9, label10, label11, label12, label13, label14, label15, label16 };
Labels.ForEach(x => x.Visible = true);
Labels.ForEach(x => x.Visible = false);
//2 Вариант: Перебор ВСЕХ(!) контролов на форме.
foreach (var item in Controls)
if (item is Label)
((Label)item).Visible = true;
foreach (var item in Controls)
if (item is Label)
((Label)item).Visible = false;
}
}
List<string> text = ["89192864554","+7926?874?22?44", "vk@yandex.ru" , "vk.com", "youtube"];
List<string> phones = new List<string>(text.Where(x => x.StartWith("+") || x.StartWith("8")));
List<string> sites = new List<string>(text.Where(x => x.Contains(".") && !x.Contains("@")));
List<string> email = new List<string>(text.Where(x => x.Contins("@")));
protected override void OnPaint(PaintEventArgs e)
{
Draw(e);
base.OnPaint(e);
}
double a = Convert.ToDouble(Console.ReadLine());
Console.WriteLine($"квадратное выражение: {a} + x^2 + {b} + x + {c}");
x1 = ((-b + (Math.Sqrt(D))) / (2 * a));
Console.WriteLine($"X1 = {(-b + (Math.Sqrt(D))) / (2 * a)}");
Console.WriteLine($"X2 = {(-b - (Math.Sqrt(D))) / (2 * a)}");
if (Console.ReadLine() == "exit")
break;