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
using System;
public class Math
{
public virtual int Sum(int a , int b)
{
return a+b;
}
}
@jskeet
jskeet / Program.cs
Created November 23, 2022 11:57
Demonstration that the code provided with the JSON provided works
using Newtonsoft.Json;
string json = "{\"Code\":\"AA10\",\"day\":\"monday\",\"errors\":[]}";
var newyvar = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
string new_row = Convert.ToString(newyvar["Code"]) + ";" + "New";
Console.WriteLine(new_row);
using Newtonsoft.Json;
string json = "{\"id\":\"5005t000004RMNTAA4\",\"success\":true,\"errors\":[]}";
var dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
Console.WriteLine(string.Join(", ", dict.Keys));
public void SetInfo(string code)
{
eventCode = code switch
{
"K" => eventCodes[0],
"L" => eventCodes[1],
"R" => eventCodes[2],
"Q" => eventCodes[3],
"N" => eventCodes[4],
_ => "I"
using System;
using System.Globalization;
class Program
{
static void Main()
{
var zone = TimeZoneInfo.FindSystemTimeZoneById("Altai Standard Time");
DateTime start = new DateTime(2013, 12, 31, 16, 0, 0, DateTimeKind.Utc);
DateTime end = start.AddHours(4);
Imports System
Module Program
Sub Main(args As String())
Dim upload As Dictionary(Of (Long, Long, Long), Long) = New Dictionary(Of (Long, Long, Long), Long)
upload.Add((1, 2, 3), 5)
End Sub
End Module
using System;
using System.Globalization;
string text = "2020-10-14T13:11:51Z";
var dt = DateTime.ParseExact(text, "yyyy'-'MM'-'dd'T'hh':'mm':'ss'Z'", CultureInfo.InvariantCulture);
Console.WriteLine(dt);
using System;
using System.Reflection;
[System.AttributeUsage(System.AttributeTargets.All, Inherited = false, AllowMultiple = true)]
sealed class CustomDateTimeAttribute : System.Attribute
{
// See the attribute guidelines at
// http://go.microsoft.com/fwlink/?LinkId=85236
readonly string positionalString;
String res =
stuff.equals("TV") ? "Walter"
: stuff.equals("Movie") ? "White"
: "No result";
using System;
using System.Collections;
using System.Collections.Generic;
class Program
{
static void Main()
{
MySetting setting = new MySetting()
{