What does this mean(Generics)
- From: "Tony" <johansson.andersson@xxxxxxxxx>
- Date: Wed, 18 Jun 2008 14:17:14 +0200
Hello!
It says "Another limitation that you need to be aware of is that using the
operator == and != are
only permitted when comparing a value of a type supplied to a generic type
to null.
That is, the following code works.
Here if T is a value type then it is always assumed to be non-null, so in
the above
code Compare always return true;"
The question is what does they mean with the text saying "using the operator
== and != are
only permitted when comparing a value of a type supplied to a generic type
to null."
public bool Compare(T op1, T op2)
{
if (op1 != null && op2 != null)
{
return true;
}
else
{
return false;
}
}
//Tony
.
- Follow-Ups:
- Re: What does this mean(Generics)
- From: Jon Skeet [C# MVP]
- Re: What does this mean(Generics)
- Prev by Date: RE: Remove user from local group
- Next by Date: Re: What does this mean(Generics)
- Previous by thread: MDI Child Form Dispose?
- Next by thread: Re: What does this mean(Generics)
- Index(es):
Loading