Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created September 5, 2023 13:36
Show Gist options
  • Save jskeet/2c61ce7f33056f643fe92df19ab25db2 to your computer and use it in GitHub Desktop.
Save jskeet/2c61ce7f33056f643fe92df19ab25db2 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
class Value
{
private readonly int x;
public Value(int x)
{
this.x = x;
}
public static implicit operator int(Value value) => value.x;
}
class Test
{
static void Main()
{
int a = 10;
Value b = new Value(20);
Console.WriteLine(a + b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment