'How to make a link clickable in c# console

I was just wondering how I could make a link in c# console clickable and be able to execute in a browser. Here is the code:

using System.Collections.Generic;
using System.Text;

namespace Project
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Click here to be redirected");
            Console.WriteLine("https://stackoverflow.com");

            Console.ReadLine();
        }
    }
}


Solution 1:[1]

This depends on the terminal emulator you use (I assume it's Command Prompt now). There is no way to change this behavior using C#.

Solution 2:[2]

If you're using the new Windows Terminal which supports this feature, you can do it thusly:

public static string TerminalURL(string caption, string url) => $"\u001B]8;;{url}\a{caption}\u001B]8;;\a";

Console.WriteLine(TerminalURL("Google", "https://google.com"));

It won't work in the legacy command prompt, but it works great in the Windows Terminal. It's backwards compatible in such a way that a terminal that doesn't support the feature will merely show the link caption as text.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sotiris Koukios-Panopoulos
Solution 2 PhonicUK