Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP inlist() in c#
Message
De
25/01/2013 13:29:39
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01320903
Message ID:
01564090
Vues:
55
>>>If I try
>>>
>>>Int16 closeDrawers = 2;
>>>
>>>if (closeDrawers.InList(2,4))
>>>
>>>
>>>
>>>I get an error about Short don't have InList implemented. I bypassed it by using Int32 instead but just wondering what was wrong in the above.
>>
>>Remind us how you are currently implementing InList() ....
>
>
> public static bool InList<T>(this T s, params T[] list)
>        {
>            return list.Contains(s);
>        }
At first sight - seems simple - replace T in the signature by Int16

closeDrawers is an Int16

The generic class above, for int 16 , will compile into
>
> public static bool InList (this Int16 s, params Int16[] list)
>        {
>            return list.Contains(s);
>        }
Which means it is expecting Int16 as parameters

Either of following solutions - not tested

(1) declare closeDrawers as Int

(2) cast closeDrawers to Int
if (((Int)closeDrawers).InList(2,4))
(3) pass shorts to Inlist
>>>if (closeDrawers.InList(  (int16)2,  (int16)4))
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform