本文整理汇总了C#中System.Collections.Specialized.StringCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# StringCollection.Add方法的具体用法?C# StringCollection.Add怎么用?C# StringCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.StringCollection
的用法示例。
在下文中一共展示了StringCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Explode
public static StringCollection Explode(string path)
{
int num2;
StringCollection strings = new StringCollection();
int startIndex = 0;
Label_0008:
num2 = path.IndexOf(SeparatorChar, startIndex);
if (num2 >= 0)
{
if (startIndex == num2)
{
strings.Add(Separator);
startIndex = num2 + 1;
}
else
{
strings.Add(path.Substring(startIndex, num2 - startIndex));
startIndex = num2;
}
goto Label_0008;
}
if (startIndex < path.Length)
{
strings.Add(path.Substring(startIndex));
}
return strings;
}
示例2: CleanWordHtml
private static string CleanWordHtml(string html)
{
StringCollection sc = new StringCollection();
// get rid of unnecessary tag spans (comments and title)
sc.Add(@"<!--(\w|\W)+?-->");
sc.Add(@"<title>(\w|\W)+?</title>");
// Get rid of classes and styles
sc.Add(@"\s?class=\w+");
sc.Add(@"\s+style='[^']+'");
// Get rid of unnecessary tags
sc.Add(
@"<(meta|link|/?o:|/?style|/?div|/?st\d|/?head|/?html|body|/?body|/?span|!\[)[^>]*?>");
// Get rid of empty paragraph tags
sc.Add(@"(<[^>]+>)+ (</\w+>)+");
// remove bizarre v: element attached to <img> tag
sc.Add(@"\s+v:\w+=""[^""]+""");
// remove extra lines
sc.Add(@"(\n\r){2,}");
foreach (string s in sc)
{
html = Regex.Replace(html, s, string.Empty, RegexOptions.IgnoreCase);
}
return html;
}
示例3: ParsePoLine
/// <summary>
/// a line in a po translation file starts with either msgid or msgstr, and can cover several lines.
/// the text is in quotes.
/// </summary>
public static string ParsePoLine(StreamReader sr, ref string ALine, out StringCollection AOriginalLines)
{
AOriginalLines = new StringCollection();
AOriginalLines.Add(ALine);
string messageId = String.Empty;
StringHelper.GetNextCSV(ref ALine, " ");
string quotedMessage = StringHelper.GetNextCSV(ref ALine, " ");
if (quotedMessage.StartsWith("\""))
{
quotedMessage = quotedMessage.Substring(1, quotedMessage.Length - 2);
}
messageId += quotedMessage;
ALine = sr.ReadLine();
while (ALine.StartsWith("\""))
{
AOriginalLines.Add(ALine);
messageId += ALine.Substring(1, ALine.Length - 2);
ALine = sr.ReadLine();
}
return messageId;
}
示例4: ClipboardFetchFilesItemTest
public void ClipboardFetchFilesItemTest()
{
string file1 = Path.GetTempFileName();
string file2 = Path.GetTempFileName();
var dummyFiles = new StringCollection();
dummyFiles.Add(file1);
dummyFiles.Add(file2);
Clipboard.Clear();
Clipboard.SetFileDropList(dummyFiles);
StringCollection copiedList = Clipboard.GetFileDropList();
Assert.AreEqual(copiedList.Count, dummyFiles.Count);
var factory = new ClipboardFileFactory();
var item = factory.CreateNewClipboardItem(IntPtr.Zero) as ClipboardFileCollection;
Assert.IsNotNull(item);
Assert.AreEqual(item.Paths.Count(), 2);
List<string> localList = item.Paths.ToList();
for (int i = 0; i < localList.Count; i++)
{
Assert.AreEqual(localList[i], dummyFiles[i]);
}
File.Delete(file1);
File.Delete(file2);
}
示例5: PeekrPop2006
///<summary>
///</summary>
public PeekrPop2006()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
// Source Queues
mqServerName.Items.Clear();
queueName.Items.Clear();
// Target Queues
targetServerCombo.Items.Clear();
targetQueueCombo.Items.Clear();
targetQueue2.Items.Clear();
// Source Machine Names
StringCollection sc = new StringCollection ();
sc.Add ("VDC3APP0006");
sc.Add ("localhost");
foreach (string s in sc)
{
mqServerName.Items.Add (s);
targetServerCombo.Items.Add (s);
}
}
示例6: ParseMultiValue
//
// <
private static string[] ParseMultiValue(string value) {
StringCollection tempStringCollection = new StringCollection();
bool inquote = false;
int chIndex = 0;
char[] vp = new char[value.Length];
string singleValue;
for (int i = 0; i < value.Length; i++) {
if (value[i] == '\"') {
inquote = !inquote;
}
else if ((value[i] == ',') && !inquote) {
singleValue = new string(vp, 0, chIndex);
tempStringCollection.Add(singleValue.Trim());
chIndex = 0;
continue;
}
vp[chIndex++] = value[i];
}
//
// Now add the last of the header values to the stringtable.
//
if (chIndex != 0) {
singleValue = new string(vp, 0, chIndex);
tempStringCollection.Add(singleValue.Trim());
}
string[] stringArray = new string[tempStringCollection.Count];
tempStringCollection.CopyTo(stringArray, 0) ;
return stringArray;
}
示例7: readBrainFile
//read brain file from disc
protected StringCollection readBrainFile()
{
StringCollection sc = new StringCollection();
if(File.Exists(filePath))
{
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
StreamReader rs = new StreamReader(fs);
string line;
while ((line = rs.ReadLine()) != null)
{
sc.Add(line);
}
rs.Close();
fs.Close();
}
else
{
MessageBox.Show("No mind file found, creating new one");
FileStream cs = File.Create(filePath);
cs.Close();
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
StreamReader rs = new StreamReader(fs);
string line;
while ((line = rs.ReadLine()) != null)
{
sc.Add(line);
}
rs.Close();
fs.Close();
}
return sc;
}
示例8: generate
/// <summary>
/// Generate statistics file
/// </summary>
/// <returns></returns>
public StringCollection generate()
{
#region delete all older files (of the same type) for this questionnaire to clean temp-Directory
try
{
foreach (string file in Directory.GetFiles(pathtotempdir, "RFG_report_statistic_*"))
{
File.Delete(file);
}
}
catch (Exception ex)
{
string dummy = ex.ToString();
}
#endregion
int statistics_records = -1;
List<string> files_names = new List<string>();
statistics_records = ReportingFacade.Format(from, until, ordering, row_number, pathtotempdir,Company_Code, ref files_names);
StringCollection retvals = new StringCollection();
retvals.Add(statistics_records.ToString());
foreach (String file in files_names)
retvals.Add(file);
return retvals;
}
示例9: DeleteUsers
public void DeleteUsers()
{
StringCollection usersToDelete = new StringCollection();
usersToDelete.Add("OtisCurry");
usersToDelete.Add("Scurry");
int userWasDeleted = awRestCalls.DeleteUsers(usersToDelete);
}
示例10: GetColumnNames
public static StringCollection GetColumnNames(string filePath, string workSheet, bool headers, int? count = null)
{
using (OleDbConnection excelConnection = new OleDbConnection(GetConnectionString(filePath, headers)))
{
StringCollection columnNames = new StringCollection();
excelConnection.Open();
String[] restriction = { null, null, workSheet, null };
DataTable dtColumns = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, restriction);
if (dtColumns == null)
throw new Exception("no columns found!");
else
{
if(count == null || count >= dtColumns.Rows.Count)
foreach (DataRow row in dtColumns.Rows)
columnNames.Add(row["COLUMN_NAME"].ToString());
else
{
for (int i = 0; i < count; i++)
columnNames.Add(dtColumns.Rows[i]["COLUMN_NAME"].ToString());
}
}
excelConnection.Close();
return columnNames;
}
}
示例11: SplitUpperCase
public static string[] SplitUpperCase(this string source)
{
if (source == null)
return new string[] {}; //Return empty array.
if (source.Length == 0)
return new[] {""};
var words = new StringCollection();
int wordStartIndex = 0;
char[] letters = source.ToCharArray();
char previousChar = char.MinValue;
// Skip the first letter. we don't care what case it is.
for (int i = 1; i < letters.Length; i++)
{
if (char.IsUpper(letters[i]) && !char.IsWhiteSpace(previousChar))
{
//Grab everything before the current index.
words.Add(new String(letters, wordStartIndex, i - wordStartIndex));
wordStartIndex = i;
}
previousChar = letters[i];
}
//We need to have the last word.
words.Add(new String(letters, wordStartIndex, letters.Length - wordStartIndex));
//Copy to a string array.
var wordArray = new string[words.Count];
words.CopyTo(wordArray, 0);
return wordArray;
}
示例12: AddElementToStringCollection
private static void AddElementToStringCollection(IElement element, ref StringCollection stringCollection,
int currentLevel, string prefix, bool isLast)
{
if (currentLevel == 0)
stringCollection.Add(element.ToString());
else
{
stringCollection.Add(prefix + "|_" + element);
if (isLast && element.ChildrenCount == 0)
stringCollection.Add(prefix);
if (isLast)
prefix += " ";
else
prefix += "| ";
}
for (int childIndex = 0; childIndex < element.ChildrenCount; childIndex++)
{
IElement child = element[childIndex];
AddElementToStringCollection(child, ref stringCollection, currentLevel + 1, prefix,
childIndex == element.ChildrenCount - 1);
}
}
示例13: SplitCamelCase
/// <summary>
/// http://weblogs.asp.net/jgalloway/archive/2005/09/27/426087.aspx
/// </summary>
public static List<string> SplitCamelCase(this string source)
{
if (source == null)
return new List<string> { }; //Return empty array.
if (source.Length == 0)
return new List<string> { "" };
StringCollection words = new StringCollection();
int wordStartIndex = 0;
char[] letters = source.ToCharArray();
// Skip the first letter. we don't care what case it is.
for (int i = 1; i < letters.Length; i++)
{
if (char.IsUpper(letters[i]))
{
//Grab everything before the current index.
words.Add(new String(letters, wordStartIndex, i - wordStartIndex));
wordStartIndex = i;
}
}
//We need to have the last word.
words.Add(new String(letters, wordStartIndex, letters.Length - wordStartIndex));
//Copy to a string array.
string[] wordArray = new string[words.Count];
words.CopyTo(wordArray, 0);
List<string> stringList = new List<string>();
stringList.AddRange(wordArray);
return stringList;
}
示例14: ParseMultiValue
private static string[] ParseMultiValue(string value)
{
StringCollection strings = new StringCollection();
bool flag = false;
int length = 0;
char[] chArray = new char[value.Length];
for (int i = 0; i < value.Length; i++)
{
if (value[i] == '"')
{
flag = !flag;
}
else if ((value[i] == ',') && !flag)
{
string str = new string(chArray, 0, length);
strings.Add(str.Trim());
length = 0;
continue;
}
chArray[length++] = value[i];
}
if (length != 0)
{
strings.Add(new string(chArray, 0, length).Trim());
}
string[] array = new string[strings.Count];
strings.CopyTo(array, 0);
return array;
}
示例15: ToStringCollection
public static StringCollection ToStringCollection(Dictionary<string, string> dic)
{
var sc = new StringCollection();
foreach (var d in dic)
{
sc.Add(d.Key);
sc.Add(d.Value);
}
return sc;
}