Skip to content

Instantly share code, notes, and snippets.

View jskeet's full-sized avatar
💭
Very happily employed. I do not wish to hear from recruiters.

Jon Skeet jskeet

💭
Very happily employed. I do not wish to hear from recruiters.
View GitHub Profile
namespace Other
{
public class List<T>
{
}
}
namespace Test
{
using Other;
using System.Text.Json;
IUser user = new User("Jon", "Reading");
string json = JsonSerializer.Serialize(user);
Console.WriteLine(json);
public interface IUser
{
string Name { get; }
class Program
{
static void Main()
{
Dictionary<string, object> dict1 = new Dictionary<string, object>()
{
{"Key1","1"},
{"Key2",2},
{"Key3","4"},
{"Key4",3},
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");
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"]);
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);
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>();
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();
using Newtonsoft.Json;
using System.Data;
var dt = new DataTable
{
Columns = { "id", "name" },
Rows = { { "x", "y" } }
};
string json = JsonConvert.SerializeObject(dt);
var options = new CreateExtractJobOptions
{
Labels = JobLabels,
LoadConfigurationModifier = op => op.UseAvroLogicalTypes = true
};