System.Configuration.CommaDelimitedStringCollection.ToString C# (CSharp) Метод

ToString() публичный Метод

public ToString ( ) : string
Результат string
        public override string ToString() {
            string returnString = null;

            if (Count > 0) {
                StringBuilder sb = new StringBuilder();
                foreach (string str in this) {
                    ThrowIfContainsDelimiter(str); // Since the add methods are not virtual they could still add bad data
                                                   // by casting the collection to a string collection.  This check will catch
                                                   // it before serialization, late is better than never.
                    sb.Append(str.Trim());
                    sb.Append(',');
                }
                returnString = sb.ToString();
                if (returnString.Length > 0) {
                    returnString = returnString.Substring(0, returnString.Length - 1);
                }
                if (returnString.Length == 0) {
                    returnString = null;
                }
            }
            return returnString;
        }

Usage Example

        public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type)
        {
            ValidateType(value, typeof(CommaDelimitedStringCollection));
            CommaDelimitedStringCollection internalValue = value as CommaDelimitedStringCollection;

            return(internalValue?.ToString());
        }
All Usage Examples Of System.Configuration.CommaDelimitedStringCollection::ToString