Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can you macro in C#/.NET?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01544610
Message ID:
01544615
Vues:
41
>Hi,
>
>Before I do the IF/ELSE, or SWITCH, I am wondering if I could macro expand in C#. Here is an example. I am passing a value of ParameterDirection as a string (e.g. 'Input', 'InputOutput', 'Output') I need to set ParameterDirection based on the passed value.
>
>Here is the pseudo code:
>
>
>string cDirection = 'Input';
>param.Direction = ParameterDirection. + 'cDirection';
>
>
>I am pretty sure that the above syntax will not work. But is there way to make it work? TIA.

Why not just pass it as parameter?
.....
Test(ParameterDirection.Input);

public void Test(ParameterDirection TestMe)
        {
...
            SqlCommand sql = new SqlCommand();
            sql.Parameters.Add("asd", SqlDbType.Int, 4);
            sql.Parameters[0].Direction = TestMe;
   ...     
        }
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform