Skip to content

Instantly share code, notes, and snippets.

View ForNeVeR's full-sized avatar
🦑

Friedrich von Never ForNeVeR

🦑
View GitHub Profile
@ForNeVeR
ForNeVeR / InitializerOrder.cs
Last active July 30, 2020 07:31
C# class constructor/initializer call order
using System;
namespace ConsoleApp5
{
class Base
{
private int _baseField = PrintAndReturnLength("Base class field init");
protected Base()
{
Console.WriteLine("Base ctor");
@ForNeVeR
ForNeVeR / DynamicCallee.cs
Created July 3, 2020 16:49
Call __arglist method with Reflection.Emit
using System;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
namespace ConsoleApp4
{
public class Program
{
public static void Callee(__arglist)
@ForNeVeR
ForNeVeR / Zombify.fs
Last active November 30, 2023 09:48
open System
let mutable debug = true
type T = T with
static member inline ($) (T, arg: unit) = ()
static member inline ($) (T, arg: int) = 0 // mandatory second terminal case; is unused in runtime but is required for the code to compile
static member inline ($) (T, func: ^a -> ^b): ^a -> ^b =
fun (_: 'a) -> T $ Unchecked.defaultof<'b>
@ForNeVeR
ForNeVeR / Union.cs
Last active April 25, 2022 15:22
A showcase of union in C#. Ha-ha.
using System;
using System.Runtime.InteropServices;
namespace ConsoleApp77
{
class User
{
public string Name { get; set; }
public string Surname { get; set; }
public string Password { get; set; }
@ForNeVeR
ForNeVeR / Program.cs
Created December 5, 2023 21:39
Thread abort in modern .NET.
// See https://aka.ms/new-console-template for more information
using System.Collections;
using System.Runtime;
internal class Program
{
public static void Main(string[] args)
{
var task = StartWork();