I’m trying to create a public property, which could either be of type long or Guid. Is it possible with generics? e.g. something like
public virtual T where T: long or Gui Id { get; set; }
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is not possible, but you can work around by using use
implicit operatorto support bothlongandGuid, sample code:Now you can use: