C# में Uri.EscapeDataString() विधि एक स्ट्रिंग को उसके बच गए प्रतिनिधित्व में बदल देती है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
public static string EscapeDataString (string str);
ऊपर, स्ट्रिंग str बचने के लिए स्ट्रिंग है।
उदाहरण
आइए अब Uri.EscapeDataString() विधि को लागू करने के लिए एक उदाहरण देखें -
using System;
public class Demo {
public static void Main(){
string URI1 = "https://www.tutorialspoint.com/index.htm";
Console.WriteLine("URI = "+URI1);
string URI2 = "https://www.tutorialspoint.com/";
Console.WriteLine("URI = "+URI2);
Console.WriteLine("\nEscaped string (URI1) = "+Uri.EscapeDataString(URI1));
Console.WriteLine("Escaped string (URI2) = "+Uri.EscapeDataString(URI2));
}
} आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
URI = https://www.tutorialspoint.com/index.htm URI = https://www.tutorialspoint.com/ Escaped string (URI1) = https%3A%2F%2Fwww.tutorialspoint.com%2Findex.htm Escaped string (URI2) = https%3A%2F%2Fwww.tutorialspoint.com%2F