System.Xml.XmlConvert.TryToUri C# (CSharp) Méthode

TryToUri() static private méthode

static private TryToUri ( string s, Uri &result ) : Exception
s string
result System.Uri
Résultat System.Exception
        internal static Exception TryToUri(string s, out Uri result)
        {
            result = null;

            if (s != null && s.Length > 0)
            { //string.Empty is a valid uri but not "   "
                s = TrimString(s);
                if (s.Length == 0 || s.IndexOf("##", StringComparison.Ordinal) != -1)
                {
                    return new FormatException(SR.Format(SR.XmlConvert_BadFormat, s, "Uri"));
                }
            }
            if (!Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out result))
            {
                return new FormatException(SR.Format(SR.XmlConvert_BadFormat, s, "Uri"));
            }
            return null;
        }