Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parameters are being ignored
Message
 
À
05/06/2006 17:44:14
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01126998
Message ID:
01127232
Vues:
11
This message has been marked as a message which has helped to the initial question of the thread.
Hi Michel,

Here is a little suggestion to refactor your original code in order to make it simplier and easier to maintain:
Private Function InList(ByVal searchedWord As String, ByVal ParamArray listOfWords() As String) As Boolean

    For Each word As String In listOfWords
        If word = searchedWord Then
            Return True
        End If
    Next
    Return False

End Function
It uses a feature from VB.NET (also existing in C#) called array parameters. The reserved word ParamArray at the function signature indicates that the function can receive a variable number of parameters from the second parameter on. The values passed as parameters are stored into an array and you can access its members as you'd normally do with regular arrays.

This makes your function work with an arbitrarly long list of parameters, which, IMHO, makes its design more flexible, optimized and robust.

HTH.
-----
Fabio Vazquez
http://www.fabiovazquez.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform