I want to write a normal function on which there is a type of constraint, especially I want something like this:
bool isInList & lt; T & gt; (T value, parameter t [] args) {bool found = false; Foreach (arg arg in arg arg) {if (arg == value) {found = true; break; }} Returned; }
The issue is that you can check whether any object parameter is in the list:
If (IsInList ("Egg", " Paneer "," egg "," ham "))
However, the compiler on the parallel line is crisp. Therefore, I would like to put an obstacle on that type of application that applies to iVictable though, barriers only work at the orbit level. Is this correct, or is there a way to specify it normally?
Generic barriers work well in normal ways:
Bool isInList & lt; T & gt; (T value, parameter t [] args) where t: iquateable & lt; T & gt;
However, IEquatable & lt; T & gt;
not defined operator ==
, only equal to (t)
.
Therefore, you should use the equals ()
and you do not even need to interrupt it: is a member of the object
Code> object .
Also do not forget that if null
equal
will not work. >
Comments
Post a Comment