How to use nameof() to get a method parameters name in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Method(int number, char ch)
        {
            Console.WriteLine(nameof(number));
            Console.WriteLine(nameof(ch));
        }

        static void Main(string[] args)
        {
            Method(13, 'F');
        }
    }
}

/*
run:

number
ch

*/

 



answered Jan 19, 2017 by avibootz
...