Nithika

Nithika

  • NA
  • 63
  • 19k

Need help in given code

Jun 18 2014 1:29 PM
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)