Uri.Fragment 屬性是實例屬性,用於獲取轉義的 URI 片段。
用法:
public string Fragment { get; }
返回值:此屬性返回包含任何 URI 片段信息的字符串。
異常:此屬性為相對 URI 拋出 InvalidOperationException 並且僅對絕對 URI 有效。
範例1:
C#
// C# program to demonstrate the
// Uri.Fragment property
using System;
using System.Globalization;
class GFG {
// Main Method
public static void Main()
{
// Declaring and initializing value1
Uri v1 = new Uri("https://www.geeksforgeeks.org/greedy-algorithms/#standardGreedyAlgorithms");
// using Fragment property
Console.WriteLine("Uri Fragment:"+ v1.Fragment);
}
}
輸出:
Uri Fragment:#standardGreedyAlgorithms
範例2:
C#
// C# program to demonstrate the
// Uri.Fragment property
using System;
using System.Globalization;
class GFG {
// Main Method
public static void Main()
{
// Declaring and initializing value1
Uri v1 = new Uri("https://www.geeksforgeeks.org/greedy-algorithms/#approximateGreedyAlgorthms");
// using Fragment property
Console.WriteLine("Uri Fragment:"+ v1.Fragment);
}
}
輸出:
Uri Fragment:#approximateGreedyAlgorthms
相關用法
- C# Console.TreatControlCAsInput用法及代碼示例
- C# Uri.DnsSafeHost用法及代碼示例
- C# StringBuilder.Chars[]用法及代碼示例
- C# Thread.CurrentThread用法及代碼示例
- C# Dictionary.Item[]用法及代碼示例
- C# Dictionary.Values用法及代碼示例
- C# Dictionary.Keys用法及代碼示例
- C# Dictionary.Count用法及代碼示例
- C# SortedDictionary.Item[]用法及代碼示例
- C# SortedDictionary.Count用法及代碼示例
- C# SortedDictionary.Keys用法及代碼示例
- C# SortedDictionary.Values用法及代碼示例
- C# Queue.Count用法及代碼示例
- C# Queue.IsSynchronized用法及代碼示例
- C# Stack.Count用法及代碼示例
- C# Stack.IsSynchronized用法及代碼示例
- C# Array.GetValue()方法用法及代碼示例
- C# File.GetLastWriteTimeUtc()用法及代碼示例
注:本文由純淨天空篩選整理自shivanisinghss2110大神的英文原創作品 Uri.Fragment Property in C# with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。