var dict = new Dictionary<string, List<string>> {
["a b"] = new List { "c", "b" },
["b"] = new List { "a", "e" },
["d c e"] = new List { "d" }
};
Console.WriteLine(dict["b"][0]);
Console.WriteLine(dict["a b"][1]);
Console.WriteLine(dict["a b"][0]);
Console.WriteLine(dict["d c e"][0]);
Console.WriteLine(dict["b"][1]);
Сталкиваюсь впервые, вопрос, как производит логирование, нужно что для всех этих библиотек-проектов подключать NLOG?
public static QueryableExtensions {
public static IQueryable<T> TakePaged<T>(this IQueryable<T> query, int take, int skip) =>
query.Take(take).Skip(skip);
}
Но я не пойму куда его запихнуть) Если впихнуть его в этот класс, где находится работа с entity, то ошибку получаю, что расширяющие методы должны быть в non-generic-классах...
Result.ToString();
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
var formData = new Dictionary<string, string>
{
{"CaseNumbers", ""},
{"Count", "25"},
{"Courts", ""},
{"DateFrom", null},
{"DateTo", null},
{"Judges", ""},
{"Page", "1"},
{"Sides", ""},
{"WithVKSInstances", "false"},
};
using var client = new HttpClient();
var uri = new Uri("https://kad.arbitr.ru/");
var content = new FormUrlEncodedContent(formData);
var response = await client.PostAsync(uri, content);
var str = await response.Content.ReadAsStringAsync();
System.IO.File.WriteAllText("./result.html", str);
using System;
using System.Collections.Generic;
using System.Text.Json;
var lines = new[]
{
"1:a",
"1:b",
"2:c",
"3:d",
"3:x",
"biba:boba:buba",
};
var result = ParseContacts(lines);
Console.WriteLine(JsonSerializer.Serialize(result, new JsonSerializerOptions(JsonSerializerDefaults.General)
{
WriteIndented = true
}));
static Dictionary<string, List<string>> ParseContacts(IEnumerable<string> lines)
{
var dict = new Dictionary<string, List<string>>();
foreach (var line in lines)
{
var tokens = line.Split(':', 2);
var id = tokens[0];
var text = tokens[1];
if (dict.ContainsKey(id))
dict[id].Add(text);
else
dict[id] = new List<string> {text};
}
return dict;
}
{
"1": [
"a",
"b"
],
"2": [
"c"
],
"3": [
"d",
"x"
],
"biba": [
"boba:buba"
]
}