2
Q:

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;
    }
}
0

New to Communities?

Join the community