This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string json = "[{\"InstanceName\":\"MyInstance\",\"name\":\"serverparam\",\"id\":\"01\"}]"; | |
| var result = System.Text.Json.JsonSerializer.Deserialize(json, typeof(Dictionary<string, string>[])); | |
| var array = (Dictionary<string, string>[]) result!; | |
| Console.WriteLine(array[0]["InstanceName"]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| string inputString = "[/OrgId] = [000000000][/StatusId] = [80][/CreatedOn] = [01/12/2023 14:29:47][/CreatedBy] = [PasdF][/PermissionFlags] = [Read][/ChangedOn] = [NOT ASSIGNED]"; | |
| string outputString = inputString.Replace("][", "?"); | |
| Console.WriteLine(outputString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics; | |
| const int CountPerInnerLoop = 10_000_000; | |
| const int Iterations = 5; | |
| for (int iteration = 1; iteration <= Iterations; iteration++) | |
| { | |
| Console.WriteLine($"Iteration {iteration}"); | |
| var list = new List<int>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using NodaTime; | |
| using System; | |
| using System.Globalization; | |
| Console.WriteLine(TimeZoneInfo.Local.Id); | |
| Console.WriteLine(DateTimeZoneProviders.Tzdb.GetSystemDefault().Id); | |
| Environment.SetEnvironmentVariable("TZ", "Europe/Paris"); | |
| TimeZoneInfo.ClearCachedData(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Newtonsoft.Json; | |
| using System.Data; | |
| var dt = new DataTable | |
| { | |
| Columns = { "id", "name" }, | |
| Rows = { { "x", "y" } } | |
| }; | |
| string json = JsonConvert.SerializeObject(dt); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var options = new CreateExtractJobOptions | |
| { | |
| Labels = JobLabels, | |
| LoadConfigurationModifier = op => op.UseAvroLogicalTypes = true | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (int i = 0; i < 10; i++) | |
| { | |
| if (i % 2 != 0) | |
| { | |
| Console.WriteLine(i); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<Quantite> list = new List<Quantite> | |
| { | |
| new Quantite | |
| { | |
| Poids = 0, | |
| Palette = 33, | |
| UniteSpecifique = "test" | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void CultureDayNameTest() | |
| { | |
| var polishCulture = CultureInfo.CreateSpecificCulture("pl-PL"); | |
| DateTime date = new DateTime(2023, 9, 16); | |
| // Format the day of the week in the Polish culture. Without specifying | |
| // the culture, the current culture is used. | |
| string stringDay = date.ToString("dddd", polishCulture); | |
| stringDay.ShouldContain(DayOfWeek.Saturday.ToString()); //Not passed | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.IO; | |
| class Value | |
| { | |
| private readonly int x; | |
| public Value(int x) | |
| { | |
| this.x = x; |