public static string GetEndpointWithPort(string endpoint, uint port) { int lastIndex = endpoint.LastIndexOf(":"); if (lastIndex < 0) throw new ArgumentException("Bad endpoint: " + endpoint); return endpoint.Substring(0, lastIndex + 1) + port; }