Define own directive?

H

Hubert Hermanutz

Hello,

for "own directives" I will define a preprocessor constant, as it was
possible with MFC with the directive "#define". Is it with C# possible for
followed C# snippet:

} catch (System.Exception clsException) { return 0; }

write only, or somethink else:
CS
?

Thanks in advance,
Hubert
 
J

Jon Skeet [C# MVP]

Hubert Hermanutz said:
for "own directives" I will define a preprocessor constant, as it was
possible with MFC with the directive "#define". Is it with C# possible for
followed C# snippet:

} catch (System.Exception clsException) { return 0; }

write only, or somethink else:
CS
?

No. Personally, I'm glad of that - it means I'll still be able to read
your code, which I certainly wouldn't be able to otherwise.
 
H

Hubert Hermanutz

Hello Jon,

C# offer direcives as "using". This directive allowed to initialized a
variable and befor this scope finalize, the "Dispose" methode from my
initialized variable were called.

Is it possible to define a constuct as using or even using myself.

Thanks in advance,
Hubert
 
J

Jon Skeet [C# MVP]

Hubert Hermanutz said:
C# offer direcives as "using". This directive allowed to initialized a
variable and befor this scope finalize, the "Dispose" methode from my
initialized variable were called.
Indeed.

Is it possible to define a constuct as using or even using myself.

No. Again, it's for readability - if everyone could create their own
directives, everyone would effectively have different versions of C#
and no-one would be able to read code from anyone else.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top