Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP inlist() in c#
Message
From
25/01/2013 13:29:39
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01320903
Message ID:
01564090
Views:
56
>>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform