monfort monfort - 1 month ago 22
C# Question

How to define a URL in C#

I have something like this

WebRequest request = WebRequest.Create("http://127.0.0.1/");


and I want to use something similar to

#define URL @""http://127.0.0.1/"
WebRequest request = WebRequest.Create(URL);


How can I do this in C#?

Answer

In C#, you use const to declare a constant, as opposed to a #define, like in C.

const string URL = @"http://127.0.0.1/";