CSharp · Console
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("Output: {0}", TestStruct.Value1);
}
}
public struct TestStruct
{
public static readonly TestStruct Value1 = 1;
public static readonly TestStruct Value2 = 2;
public static readonly TestStruct Value3 = 3;
private int _value;
private TestStruct(int value)
{
_value = value;
}
public static implicit operator int(TestStruct instance)
{
return instance._value;
}
public static implicit operator TestStruct(int instance)
{
return new TestStruct(instance);
}
}