C# Macro definitions in Preprocessor

cl123 picture cl123 · Apr 2, 2009 · Viewed 127.9k times · Source

Is C# able to define macros as is done in the C programming language with pre-processor statements? I would like to simplify regular typing of certain repeating statements such as the following:

Console.WriteLine("foo");

Answer

Andrew Hare picture Andrew Hare · Apr 2, 2009

No, C# does not support preprocessor macros like C. Visual Studio on the other hand has snippets. Visual Studio's snippets are a feature of the IDE and are expanded in the editor rather than replaced in the code on compilation by a preprocessor.