var sortedValues = dataForToken.OrderBy(pair => pair.Key).Select(pair => pair.Value);
var concatenatedString = string.Join("", sortedValues);
[Serializable]
public class LevelsConfigDto
{
[JsonProperty("version")] public int? Version { get; set; }
[JsonProperty("levelParams")] public List<LevelParam>? LevelParams { get; set; }
}
public static void MepLevelsConfig(LevelsConfig target, LevelsConfigDto source)
{
if (source.Version != null)
{
target.Version = source.Version;
}
if (source.LevelParam != null)
{
var count = Math.Min(target.LevelParam.Count, source.LevelParam.Count);
for (int i = 0; i < count; i++)
{
target.LevelParam[i].Steps = source.LevelParam[i].Steps;
target.LevelParam[i].Complexity = source.LevelParam[i].Complexity;
}
if (source.LevelParam.Count > target.LevelParam.Count)
{
for (int i = target.LevelParam.Count; i < source.LevelParam.Count; i++)
{
target.LevelParam.Add(source.LevelParam[i]);
}
}
}
}
byte[] buffer1 = await webClient.DownloadDataTaskAsync(firstUrl);
byte[] buffer2 = await webClient.DownloadDataTaskAsync(secondUrl);
using (FileStream stream = new FileStream("file.data", FileMode.Create))
{
stream.Write(buffer1, 0, buffer1.Length);
stream.Write(buffer2, 0, buffer2.Length);
}
string[] urls = { /* URL адреса файлов */ };
string[] filesNames = { /* имена файлов */ };
// параллельно скачиваем файлы
await Task.WhenAll(urls.Select((url, i) => webClient.DownloadFileTaskAsync(url, filesNames[i])));
// открываем на запись первый файл
using (Stream resultFileStream = File.OpenWrite(filesNames[0]))
{
// открываем на чтение второй файл
using (Stream fileStream = File.OpenRead(filesNames[1]))
{
// копируем поток байтов из второго файла в первый
fileStream.CopyTo(resultFileStream);
}
}
// удаляем второй файл
File.Delete(filesNames[1]);
class Human
{
public string Name { get; set }
}
class Human
{
private string _name;
public string GetName()
{
return this._name;
}
public void SetName(string value)
{
this._name = value;
}
}
class Human
{
private string _phone;
public string Phone
{
get => "Human phone" + this._phone;
set =>
{
this._phone = value;
if (value[0] != '+') this._phone = "+" + this._phone;
}
}
}
class Human
{
private string _phone;
public string GetPhone()
{
return "Human phone: " + this._phone;
}
public void SetPhone(string value)
{
this._phone = value;
if (value[0] != '+') this._phone = "+" + this._phone;
}
}
var human = new Human();
human.Name = "John";
Console.WriteLine(human.Name);
Human human = new Human();
human.SetName("John");
Console.WriteLine(human.GetName());
partial class MyForm
{
private SoundPlayer Player = new SoundPlayer(Properties.Resources.SoundName);
private void PlayAudio()
{
// Если нужно загружать именно по нажатию кнопки
// this.Player = new SoundPlayer(Properties.Resources.SoundName);
this.Player.PlayLooping();
}
}
async Task<string> SendRequestUntilSuccess(string url)
{
try
{
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
return response.Content.ReadAsStringAsync();
}
catch(HttpRequestException e)
{
return SendRequestUntilSuccess(url);
}
}