This file contains 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
namespace Other | |
{ | |
public class List<T> | |
{ | |
} | |
} | |
namespace Test | |
{ | |
using Other; |
This file contains 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.Text.Json; | |
IUser user = new User("Jon", "Reading"); | |
string json = JsonSerializer.Serialize(user); | |
Console.WriteLine(json); | |
public interface IUser | |
{ | |
string Name { get; } |
This file contains 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
class Program | |
{ | |
static void Main() | |
{ | |
Dictionary<string, object> dict1 = new Dictionary<string, object>() | |
{ | |
{"Key1","1"}, | |
{"Key2",2}, | |
{"Key3","4"}, | |
{"Key4",3}, |
This file contains 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.Linq; | |
using System.Xml.Linq; | |
var doc = XDocument.Load("test.xml"); | |
var matches = doc | |
.Descendants("aircraft_info") | |
.Where(ft => ((string)ft.Element("aircraft_name")) == "Default"); | |
This file contains 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 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 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 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 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 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 | |
}; |
NewerOlder