Вопрос

In the following program I wrote in C#:

static void Main(string[] args)
        {
            paramsAndOptionalTest(1,2);

#pragma region CmdLineStuff
            for (int i = 0; i < args.Length; i++)
            {
                Console.WriteLine("{0}", args[i]);
            }
            foreach (string arg in args)
            {
                Console.WriteLine(arg);
            }
            string[] apiargs = Environment.GetCommandLineArgs();//this will give the executable name and path too
            int exitCode = Environment.ExitCode;
            foreach (string arg in apiargs)
            {
                Console.WriteLine(arg);

            }
            Console.WriteLine("Exit Code {0}", exitCode);
            string myString = string.Format("11 in hexa is {0:x}", 11);
            System.Windows.MessageBox.Show(myString);

#pragma endregion CmdLineStuff
            ImmutableStrings();
            Console.ReadLine();
        }

I used the #pragma region. But I am getting CS1633: Unrecognized #pragma directive warning.So I think C# compiler doesn't recognize this Pragma where as in C++ it worked fine.Is there any equivalent for this pragma in C#?

Это было полезно?

Решение

It is simply

#region CmdLineStuff
......
#endregion CmdLineStuff

The docs could be found here and here there is the full documentation for the C# Preprocessor directives

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top