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 Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
class Program
{
static async Task Main()
{
using IHost host = Host.CreateDefaultBuilder()
.ConfigureServices(services =>
delegate void SampleDelegate(string text);
class Test
{
static void Main()
{
string x = "";
var del = new SampleDelegate(Method, x);
}
using System;
using System.Text;
public class Program
{
static void Main()
{
var builder = new StringBuilder();
for (int i = 0; i < 256; i++)
{
import org.json.JSONObject;
public class Test {
public static void main(String args[]) {
String json = "{ \"status\": \"failed\", \"message\": \"All fields are required\" }";
JSONObject jsonObject = new JSONObject(json);
String status = jsonObject.getString("status");
String message = jsonObject.getString("message");
using System;
using System.IO;
using System.Collections.Generic;
public interface IWriterService
{
Stream WriteTXT<T>(List<T> content, string delimator, string header = "", bool isHeader = false) where T : class;
}
public class WriterService : IWriterService
using System;
using System.IO;
using System.Collections.Generic;
public interface IWriterService
{
Stream WriteTXT<T>(List<T> content, string delimiter,
string header, bool isHeader)
where T : class;
}
using System;
using System.Collections.Generic;
using System.Linq;
List<string> list1 = new List<string> {"1", "2", "3"};
List<string> list2 = new List<string> {"1", "2", "3"};
// Prints True
Console.WriteLine(list1.SequenceEqual(list2));
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));