System.Net.Mail.MailAddressParser.ParseAddress C# (CSharp) Method

ParseAddress() static private method

static private ParseAddress ( string data ) : System.Net.Mail.MailAddress
data string
return System.Net.Mail.MailAddress
        internal static MailAddress ParseAddress(string data)
        {
            int index = data.Length - 1;
            MailAddress parsedAddress = MailAddressParser.ParseAddress(data, false, ref index);
            Debug.Assert(index == -1, "The index indicates that part of the address was not parsed: " + index);
            return parsedAddress;
        }

Same methods

MailAddressParser::ParseAddress ( string data, bool expectMultipleAddresses, int &index ) : System.Net.Mail.MailAddress

Usage Example

        public MailAddress(string address, string displayName, Encoding displayNameEncoding)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (address == string.Empty)
            {
                throw new ArgumentException(SR.GetString("net_emptystringcall", new object[] { "address" }), "address");
            }
            this.displayNameEncoding = displayNameEncoding ?? Encoding.GetEncoding("utf-8");
            this.displayName         = displayName ?? string.Empty;
            if ((!string.IsNullOrEmpty(this.displayName) && (this.displayName.Length >= 2)) && ((this.displayName[0] == '"') && (this.displayName[this.displayName.Length - 1] == '"')))
            {
                this.displayName = this.displayName.Substring(1, this.displayName.Length - 2);
            }
            MailAddress address2 = MailAddressParser.ParseAddress(address);

            this.host     = address2.host;
            this.userName = address2.userName;
            if (string.IsNullOrEmpty(this.displayName))
            {
                this.displayName = address2.displayName;
            }
        }
All Usage Examples Of System.Net.Mail.MailAddressParser::ParseAddress