UriHelper.WithFragment Method

Namespace
Kampute.DocToolkit.Support
Assembly
  • Kampute.DocToolkit.dll

Definition

Creates a new Uri with the specified fragment added.
public static Uri WithFragment(this Uri uri, string fragment)

Parameters

uri Uri
The Uri instance to append the fragment to.
fragment string
The fragment to append to the URI.

Returns

Uri
A new Uri with the fragment added.

Exceptions

ArgumentNullException
Thrown when uri is null.

Remarks

This method creates a new Uri instance with the specified fragment. If the original URI already has a fragment, the new fragment replaces the existing one. If the new fragment is is an empty string, the fragment part is removed.
This method is useful for creating anchored links within documentation pages while preserving the original URI structure.