c# how long does a type cast operation take code example
Example: how to make a class implicitly convertible C#
public class ExampleClass
{
private static int storedInt = 10;
public int Integer
{
get => storedInt;
set => storedInt = value;
}
public ExampleClass(int storedNumber)
{
storedInt = storedNumber;
}
public static implicit operator ExampleClass(int value)
{
ExampleClass x = new ExampleClass(value);
x.Integer = value;
return x;
}
}