Courant
(1)
Numero
(1)
Preprocesseurs
(1)
Éventuellement
(1)
B6E8BCC69CB4
(1)
Responsable
(1)
Compilateur
(1)
Normalement
(1)

utilisation de "define"

Asked By Maurice60
20-Nov-09 02:48 AM
bjr
dans nos projet en c++ on utilisaot bcp ce genre de macro
while(Courant)   \
{\
if(dynamic_cast<a *>(Courant))\
if((dynamic_cast<a *>(Courant))->Numero == no)\
return (a *) Courant;\
Courant = Courant->Next;\
}\
return NULL;\

peut-on faire la meme chose en c#?
merci

Bonjour,Pas "out of the box".

Patrice replied to Maurice60
20-Nov-09 05:16 AM
Bonjour,

Pas "out of the box". Il doit y avoir éventuellement des preprocesseurs
tiers si l'on veut vraiment faire des macros. Sinon c'est normalement le
compilateur qui est responsable de mettre le code "inline" si il le trouve
opportun.

--
Patrice


groupe de discussion : CD78F80A-0266-4B2B-A3DF-B6E8BCC69CB4@microsoft.com...

groupe de discussion : CD78F80A-0266-4B2B-A3DF-B6E8BCC69CB4@microsoft.com...

Christophe Lephay replied to Maurice60
23-Nov-09 12:10 AM
groupe de discussion : CD78F80A-0266-4B2B-A3DF-B6E8BCC69CB4@microsoft.com...

L'op??rateur as fonctionne comme le dynamic_cast (renvoie null si la
conversion ??choue).

En mot ?? mot, ??a donne :

if (Courant is a)
if ( (Courant as a).Numero == no)
return (a)Courant;
Courant = Courant.Next;

Sinon, on peut faire la conversion une seule fois :

a* Courant_a = dynamic_cast<a*>(Courant);
if (Courant_a && Courant_a->Numero == no)
return Courant_a;

donnerait en c# :

a Courant_a = Courant as a;
if (Courant_a != null && Courant_a.Numero == no)
return Courant_a;
Post Question To EggHeadCafe