3
Answers

Need help in given code

Nithika

Nithika

10y
896
1
Hello Friends,
I am getting error 'cannot convert null to Sample<int>' in below code. Please tell me, why I am getting this error.
struct Sample<T> where T : struct
{
  private T inputValue;
  public T Value
  {
  get
  {
  return inputValue;
  }
  }
  public static implicit operator Sample<T>(T value)
  {
  return new Sample<T>(value);
  }
  public Sample(T value)
  {
  inputValue = value;
  }
 }
 static void Main(string[] args)
  {
  Sample<int> t = null;
  }

Answers (3)