Skip to content

Instantly share code, notes, and snippets.

@wallymathieu
Created September 21, 2017 07:45
Show Gist options
  • Select an option

  • Save wallymathieu/61d1bc9d824fceca0c75f772b6995f3d to your computer and use it in GitHub Desktop.

Select an option

Save wallymathieu/61d1bc9d824fceca0c75f772b6995f3d to your computer and use it in GitHub Desktop.
Sample combine URI in c#
using System;
namespace Namespace
{
/// <summary>
/// Uri helpers
/// </summary>
public static class Uris
{
/// <summary>
/// Create a new Uri based on base uri and relative path
/// </summary>
public static Uri Create(string baseUri, string relativePath)=>
Uri.TryCreate(new Uri(baseUri), relativePath, out var combinedUri)
? combinedUri
: throw new Exception($"Could not combine base uri : {baseUri} with relative path: {relativePath}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment