Microsoft Visual Studio 2019 IntelliCode

Microsoft came up with amazing featuring in Visual Studio 2019, called IntelliCode. IntelliCode assisted IntelliSense in visual studio 2019 based on artificial intelligence (AI). It provides IntelliSense based on context and usage. IntelliCode suggestions appear at the list with a star icon left to them.

We can install IntelliCode through extensions. Open Microsoft Visual Studio 2019 => select Extensions => Manage Extensions option, extension window displays as below.

Please install it if not installed before. To enable IntelliCode option, go to Tools => select Options => All Languages => General and select “Auto list members” as shown below.

Let’s see the IntelliCode functionality through example. As I already told you, IntelliCode gives suggestions based on usage and context. To allow the IntelliCode to provide the suggestions, first we need to select option which has star icon (*) left to them as below.

Here we selected IntelliCode suggestion Replace for filePath variable. Because of this, wherever we use the filePath variable, IntelliCode provides the options related to context, as shown below.

As we see here, IntelliCode displays the options as “Contains”, “StartsWith”, “EndsWith”, and “Replace” which are related to the current context for filePath variable.

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string filePath = "C:\\data/uploads/datafile1.txt/";

            filePath = filePath.Replace("\\", "/");

            if(filePath.EndsWith("/"))
            {
                filePath = filePath.Substring(0, filePath.Length - 1);
            }            
        }       
    }
}