DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Kenichiro Nakamura
Kenichiro Nakamura

Posted on

I never pass wrong parameter values to a method again with Visual Studio 2019

Have you ever pass wrong parameter values to a method because:

  • The method has too many parameters
  • There are also default values for parameters
  • There are many overrides

Of course Visual Studio let you know when you pass wrong type, but not for the same type.

Let's see the simplest example.

using System;

namespace SampleConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var me = new Person("kenichiro", "nakamura");
            Console.WriteLine($"Hello {me.Firstname} {me.Lastname}");
        }
    }

    class Person
    {
        public string Firstname { get; set; }
        public string Lastname { get; set; }
        public Person(string firstname, string lastname)
        {
            this.Firstname = firstname;
            this.Lastname = lastname;
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

When I write code, Visual Studio helps me by showing parameter name.

Alt Text

However, after I finish entering values, now I don't see any hint.

Alt Text

Enable Experimental Feature

The latest Visual Studio 2019 has following option.

Alt Text

Once you enable it, you can see parameter names like this.

Alt Text

Of course, the official document has this information here

Who need this feature?

I do. But it's not required for everyone, every time. There was a discussion in GitHub issue which suggest some improvements and re-consideration.

So I recommend you to try out first, then if it bothers you, you can turn it off anytime without restarting your VS 2019.

Top comments (0)

๐ŸŒš Turn on dark mode

๐Ÿ”  Change your default font

๐Ÿ“š Adjust your experience level to see more relevant content

ย 

Head to your account's Settings to do all this and more.