Answers for "how to make a class implicitly convertible C#"

C#
0

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;
    }
}
Posted by: Guest on August-15-2020

Code answers related to "how to make a class implicitly convertible C#"

C# Answers by Framework

Browse Popular Code Answers by Language