C# URI 주요 변수 값 출력 테스트

0 투표
using System;

class Program
{
    static void Main()
    {
        // Construct three Uri objects.
        Uri uri1 = new Uri("http://www.nanumtip.com/");
        Uri uri2 = new Uri(uri1, "/qa/nanumtip/");
        Uri uri3 = new Uri("https://www.nanumtip.com/qa/search?q=domain");

        // Write properties.
        Print(uri1);
        Print(uri2);
        Print(uri3);
    }

    static void Print(Uri uri)
    {
        // Print properties of Uri instance.
        Console.WriteLine("AbsolutePath = {0}", uri.AbsolutePath);
        Console.WriteLine("AbsoluteUri = {0}", uri.AbsoluteUri);
        Console.WriteLine("Authority = {0}", uri.Authority);
        Console.WriteLine("DnsSafeHost = {0}", uri.DnsSafeHost);
        Console.WriteLine("Fragment = {0}", uri.Fragment);
        Console.WriteLine("Host = {0}", uri.Host);
        Console.WriteLine("HostNameType = {0}", uri.HostNameType);
        Console.WriteLine("IsAbsoluteUri = {0}", uri.IsAbsoluteUri);
        Console.WriteLine("IsDefaultPort = {0}", uri.IsDefaultPort);
        Console.WriteLine("IsFile = {0}", uri.IsFile);
        Console.WriteLine("IsLoopback = {0}", uri.IsLoopback);
        Console.WriteLine("IsUnc = {0}", uri.IsUnc);
        Console.WriteLine("LocalPath = {0}", uri.LocalPath);
        Console.WriteLine("OriginalString = {0}", uri.OriginalString);
        Console.WriteLine("PathAndQuery = {0}", uri.PathAndQuery);
        Console.WriteLine("Port = {0}", uri.Port);
        Console.WriteLine("Query = {0}", uri.Query);
        Console.WriteLine("Scheme = {0}", uri.Scheme);
        Console.WriteLine("Segments = {0}", string.Join(",", uri.Segments));
        Console.WriteLine("UserEscaped = {0}", uri.UserEscaped);
        Console.WriteLine("UserInfo = {0}", uri.UserInfo);
        Console.WriteLine(new string('-', 40));
    }
}

1 답변

0 투표
AbsolutePath = /
AbsoluteUri = http://www.nanumtip.com/
Authority = www.nanumtip.com
DnsSafeHost = www.nanumtip.com
Fragment =
Host = www.nanumtip.com
HostNameType = Dns
IsAbsoluteUri = True
IsDefaultPort = True
IsFile = False
IsLoopback = False
IsUnc = False
LocalPath = /
OriginalString = http://www.nanumtip.com/
PathAndQuery = /
Port = 80
Query =
Scheme = http
Segments = /
UserEscaped = False
UserInfo =
----------------------------------------
AbsolutePath = /qa/221155/
AbsoluteUri = http://www.nanumtip.com/qa/221155/
Authority = www.nanumtip.com
DnsSafeHost = www.nanumtip.com
Fragment =
Host = www.nanumtip.com
HostNameType = Dns
IsAbsoluteUri = True
IsDefaultPort = True
IsFile = False
IsLoopback = False
IsUnc = False
LocalPath = /qa/221155/
OriginalString = http://www.nanumtip.com/qa/221155/
PathAndQuery = /qa/221155/
Port = 80
Query =
Scheme = http
Segments = /,qa/,221155/
UserEscaped = False
UserInfo =
----------------------------------------
AbsolutePath = /qa/search
AbsoluteUri = https://www.nanumtip.com/qa/search?q=domain
Authority = www.nanumtip.com
DnsSafeHost = www.nanumtip.com
Fragment =
Host = www.nanumtip.com
HostNameType = Dns
IsAbsoluteUri = True
IsDefaultPort = True
IsFile = False
IsLoopback = False
IsUnc = False
LocalPath = /qa/search
OriginalString = https://www.nanumtip.com/qa/search?q=domain
PathAndQuery = /qa/search?q=domain
Port = 443
Query = ?q=domain
Scheme = https
Segments = /,qa/,search
UserEscaped = False
UserInfo =
----------------------------------------
구로역 맛집 시흥동 맛집
이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.
add
...