Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameters are being ignored
Message
From
06/06/2006 14:14:40
 
 
To
06/06/2006 13:36:38
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01126998
Message ID:
01127438
Views:
14
>Here is a sample in C#:
>
>using System;
>using System.Collections.Generic;
>
>class myInList
>{
>  static void Main()
>  {
>     DateTime t = DateTime.Now;
>     string[] myStringList = {"john","frank","michel"};
>     int[] myIntList = {4,5,12,23};
>     DateTime[] myDateTimes = { t, t.AddDays(1), t.AddDays(-1)};
>  Console.WriteLine("{0} is inlist: {1}", "michel",InList<string>( "michel", myStringList ) ) ;
>  Console.WriteLine("{0} is inlist: {1}", "cetin", InList<string>( "cetin", myStringList ) ) ;
>
>  Console.WriteLine("{0} is inlist: {1}", 5, InList<int>( 5, myIntList ) ) ;
>  Console.WriteLine("{0} is inlist: {1}", 1, InList<int>( 1, myIntList ) ) ;
>
>  Console.WriteLine("{0} is inlist: {1}", t, InList<DateTime>( t, myDateTimes ) ) ;
>  Console.WriteLine("{0} is inlist: {1}", t.AddDays(1), InList<DateTime>( t.AddDays(1), myDateTimes ) ) ;
>  Console.WriteLine("{0} is inlist: {1}", t.AddDays(2), InList<DateTime>( t.AddDays(2), myDateTimes ) ) ;
>
>  }
> public static bool InList<T>(T searchFor, T[] searchInList) where T : IComparable<T>
> {
>   return ( Array.IndexOf(searchInList,searchFor) != -1 );
> }
>}
>
Thanks, this is really good. Here is the conversion:
        ' VFP inlist equivalent
        ' expO1 Item where all the items will be tried to look into
        ' expO2 Param array for a list of items
        Public Function Inlist(ByVal toItem As IComparable, ByVal ParamArray toItems() As IComparable) As Boolean
            Return Array.IndexOf(toItems, toItem) <> -1
        End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform