System.Net.Mime.HeaderCollection.GetValues C# (CSharp) Method

GetValues() public method

public GetValues ( string name ) : string[]
name string
return string[]
        public override string[] GetValues(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (name == string.Empty)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(name)), nameof(name));
            }

            MailHeaderID id = MailHeaderInfo.GetID(name);

            if (id == MailHeaderID.ContentType && _part != null)
            {
                _part.ContentType.PersistIfNeeded(this, false);
            }
            else if (id == MailHeaderID.ContentDisposition && _part is MimePart)
            {
                ((MimePart)_part).ContentDisposition.PersistIfNeeded(this, false);
            }
            return base.GetValues(name);
        }

Usage Example

 internal void EncodeHeaders(HeaderCollection headers)
 {
     if (this.headersEncoding == null)
     {
         this.headersEncoding = Encoding.GetEncoding("utf-8");
     }
     for (int i = 0; i < headers.Count; i++)
     {
         string key = headers.GetKey(i);
         if (MailHeaderInfo.IsUserSettable(key))
         {
             string[] values = headers.GetValues(key);
             string str2 = string.Empty;
             for (int j = 0; j < values.Length; j++)
             {
                 if (MimeBasePart.IsAscii(values[j], false))
                 {
                     str2 = values[j];
                 }
                 else
                 {
                     str2 = MimeBasePart.EncodeHeaderValue(values[j], this.headersEncoding, MimeBasePart.ShouldUseBase64Encoding(this.headersEncoding), key.Length);
                 }
                 if (j == 0)
                 {
                     headers.Set(key, str2);
                 }
                 else
                 {
                     headers.Add(key, str2);
                 }
             }
         }
     }
 }
All Usage Examples Of System.Net.Mime.HeaderCollection::GetValues