自定义中的 C# StringCollection Class
C# StringCollection in Custom Class
鉴于下面的 class,将多个字符串添加到名为 blob_key_col_name 的 StringCollection 的正确方法是什么?
public class blob_info
{
public string column_name { get; set; }
public string blob_value { get; set; }
public int column_pos { get; set; }
public string blob_key { get; set; }
public int blob_key_count { get; set; }
public StringCollection blob_key_col_name { get; set; }
public blob_info(string column_name, string blob_value, int column_pos, string blob_key, int blob_key_count)
{
this.column_name = column_name;
this.blob_value = blob_value;
this.column_pos = column_pos;
this.blob_key = blob_key;
this.blob_key_count = blob_key_count;
blob_key_col_name = new StringCollection();
}
}
public static List<blob_info> blob_col = new List<blob_info>();
void main
{
blob_col.Add(new blob_info("Column_name","pathname",0,"key_column_name",0,blob_key_col_name.Add("")));
}
那就是使用:
string[] myStringArray = new[] {"aa","bb","cc"};
blob_col.blob_key_col_name.AddRange(myStringArray);
查看文档了解更多详情。 https://msdn.microsoft.com/en-us/library/system.collections.specialized.stringcollection(v=vs.110).aspx
鉴于下面的 class,将多个字符串添加到名为 blob_key_col_name 的 StringCollection 的正确方法是什么?
public class blob_info
{
public string column_name { get; set; }
public string blob_value { get; set; }
public int column_pos { get; set; }
public string blob_key { get; set; }
public int blob_key_count { get; set; }
public StringCollection blob_key_col_name { get; set; }
public blob_info(string column_name, string blob_value, int column_pos, string blob_key, int blob_key_count)
{
this.column_name = column_name;
this.blob_value = blob_value;
this.column_pos = column_pos;
this.blob_key = blob_key;
this.blob_key_count = blob_key_count;
blob_key_col_name = new StringCollection();
}
}
public static List<blob_info> blob_col = new List<blob_info>();
void main
{
blob_col.Add(new blob_info("Column_name","pathname",0,"key_column_name",0,blob_key_col_name.Add("")));
}
那就是使用:
string[] myStringArray = new[] {"aa","bb","cc"};
blob_col.blob_key_col_name.AddRange(myStringArray);
查看文档了解更多详情。 https://msdn.microsoft.com/en-us/library/system.collections.specialized.stringcollection(v=vs.110).aspx