|
1 | 1 | using System;
|
2 |
| -using System.Data; |
3 | 2 | using System.Net;
|
4 | 3 | using System.Windows.Forms;
|
5 | 4 |
|
6 |
| -public class Form1: Form |
| 5 | +public class Form1 : Form |
7 | 6 | {
|
8 |
| - protected void Method() |
9 |
| - { |
10 |
| -Uri uri = new Uri("https://user:[email protected]:80/Home/Index.htm?q1=v1&q2=v2#FragmentName"); |
11 |
| -Console.WriteLine("AbsolutePath: {0}", uri.AbsolutePath); |
12 |
| -Console.WriteLine("AbsoluteUri: {0}", uri.AbsoluteUri); |
13 |
| -Console.WriteLine("DnsSafeHost: {0}", uri.DnsSafeHost); |
14 |
| -Console.WriteLine("Fragment: {0}", uri.Fragment); |
15 |
| -Console.WriteLine("Host: {0}", uri.Host); |
16 |
| -Console.WriteLine("HostNameType: {0}", uri.HostNameType); |
17 |
| -Console.WriteLine("IdnHost: {0}", uri.IdnHost); |
18 |
| -Console.WriteLine("IsAbsoluteUri: {0}", uri.IsAbsoluteUri); |
19 |
| -Console.WriteLine("IsDefaultPort: {0}", uri.IsDefaultPort); |
20 |
| -Console.WriteLine("IsFile: {0}", uri.IsFile); |
21 |
| -Console.WriteLine("IsLoopback: {0}", uri.IsLoopback); |
22 |
| -Console.WriteLine("IsUnc: {0}", uri.IsUnc); |
23 |
| -Console.WriteLine("LocalPath: {0}", uri.LocalPath); |
24 |
| -Console.WriteLine("OriginalString: {0}", uri.OriginalString); |
25 |
| -Console.WriteLine("PathAndQuery: {0}", uri.PathAndQuery); |
26 |
| -Console.WriteLine("Port: {0}", uri.Port); |
27 |
| -Console.WriteLine("Query: {0}", uri.Query); |
28 |
| -Console.WriteLine("Scheme: {0}", uri.Scheme); |
29 |
| -Console.WriteLine("Segments: {0}", string.Join(", ", uri.Segments)); |
30 |
| -Console.WriteLine("UserEscaped: {0}", uri.UserEscaped); |
31 |
| -Console.WriteLine("UserInfo: {0}", uri.UserInfo); |
| 7 | + protected void Method() |
| 8 | + { |
| 9 | + // <Snippet1> |
| 10 | + Uri contoso = new Uri("http://www.contoso.com/"); |
32 | 11 |
|
33 |
| -// AbsolutePath: /Home/Index.htm |
34 |
| -// AbsoluteUri: https://user:[email protected]:80/Home/Index.htm?q1=v1&q2=v2#FragmentName |
35 |
| -// DnsSafeHost: www.contoso.com |
36 |
| -// Fragment: #FragmentName |
37 |
| -// Host: www.contoso.com |
38 |
| -// HostNameType: Dns |
39 |
| -// IdnHost: www.contoso.com |
40 |
| -// IsAbsoluteUri: True |
41 |
| -// IsDefaultPort: False |
42 |
| -// IsFile: False |
43 |
| -// IsLoopback: False |
44 |
| -// IsUnc: False |
45 |
| -// LocalPath: /Home/Index.htm |
46 |
| -// OriginalString: https://user:[email protected]:80/Home/Index.htm?q1=v1&q2=v2#FragmentName |
47 |
| -// PathAndQuery: /Home/Index.htm?q1=v1&q2=v2 |
48 |
| -// Port: 80 |
49 |
| -// Query: ?q1=v1&q2=v2 |
50 |
| -// Scheme: https |
51 |
| -// Segments: /, Home/, Index.htm |
52 |
| -// UserEscaped: False |
53 |
| -// UserInfo: user:password |
| 12 | + WebRequest wr = WebRequest.Create(contoso); |
| 13 | + // </Snippet1> |
| 14 | + |
| 15 | + // <Snippet2> |
| 16 | + Uri uri = new Uri("https://user:[email protected]:80/Home/Index.htm?q1=v1&q2=v2#FragmentName"); |
| 17 | + |
| 18 | + Console.WriteLine($"AbsolutePath: {uri.AbsolutePath}"); |
| 19 | + Console.WriteLine($"AbsoluteUri: {uri.AbsoluteUri}"); |
| 20 | + Console.WriteLine($"DnsSafeHost: {uri.DnsSafeHost}"); |
| 21 | + Console.WriteLine($"Fragment: {uri.Fragment}"); |
| 22 | + Console.WriteLine($"Host: {uri.Host}"); |
| 23 | + Console.WriteLine($"HostNameType: {uri.HostNameType}"); |
| 24 | + Console.WriteLine($"IdnHost: {uri.IdnHost}"); |
| 25 | + Console.WriteLine($"IsAbsoluteUri: {uri.IsAbsoluteUri}"); |
| 26 | + Console.WriteLine($"IsDefaultPort: {uri.IsDefaultPort}"); |
| 27 | + Console.WriteLine($"IsFile: {uri.IsFile}"); |
| 28 | + Console.WriteLine($"IsLoopback: {uri.IsLoopback}"); |
| 29 | + Console.WriteLine($"IsUnc: {uri.IsUnc}"); |
| 30 | + Console.WriteLine($"LocalPath: {uri.LocalPath}"); |
| 31 | + Console.WriteLine($"OriginalString: {uri.OriginalString}"); |
| 32 | + Console.WriteLine($"PathAndQuery: {uri.PathAndQuery}"); |
| 33 | + Console.WriteLine($"Port: {uri.Port}"); |
| 34 | + Console.WriteLine($"Query: {uri.Query}"); |
| 35 | + Console.WriteLine($"Scheme: {uri.Scheme}"); |
| 36 | + Console.WriteLine($"Segments: {string.Join(", ", uri.Segments)}"); |
| 37 | + Console.WriteLine($"UserEscaped: {uri.UserEscaped}"); |
| 38 | + Console.WriteLine($"UserInfo: {uri.UserInfo}"); |
| 39 | + |
| 40 | + // AbsolutePath: /Home/Index.htm |
| 41 | + // AbsoluteUri: https://user:[email protected]:80/Home/Index.htm?q1=v1&q2=v2#FragmentName |
| 42 | + // DnsSafeHost: www.contoso.com |
| 43 | + // Fragment: #FragmentName |
| 44 | + // Host: www.contoso.com |
| 45 | + // HostNameType: Dns |
| 46 | + // IdnHost: www.contoso.com |
| 47 | + // IsAbsoluteUri: True |
| 48 | + // IsDefaultPort: False |
| 49 | + // IsFile: False |
| 50 | + // IsLoopback: False |
| 51 | + // IsUnc: False |
| 52 | + // LocalPath: /Home/Index.htm |
| 53 | + // OriginalString: https://user:[email protected]:80/Home/Index.htm?q1=v1&q2=v2#FragmentName |
| 54 | + // PathAndQuery: /Home/Index.htm?q1=v1&q2=v2 |
| 55 | + // Port: 80 |
| 56 | + // Query: ?q1=v1&q2=v2 |
| 57 | + // Scheme: https |
| 58 | + // Segments: /, Home/, Index.htm |
| 59 | + // UserEscaped: False |
| 60 | + // UserInfo: user:password |
54 | 61 |
|
55 |
| -// </Snippet1> |
56 |
| - } |
| 62 | + // </Snippet2> |
| 63 | + } |
57 | 64 | }
|
0 commit comments