本文介绍了如何在C Sharp中的字符串数组中添加字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生
在我的C语言编程中
在以下代码中
string [] readText = File.ReadAllLines(path);
readText包含10000行的数组
现在我创建了两个字符串数组变量
Sir
In my c sharp programming
in following code
string[] readText = File.ReadAllLines(path);
readText contains array of 10000 rows
now i created two string array variable
string[] badEmail;
string[] goodemail;
在下面的代码中,我使用validEmail(readText [i])方法检查电子邮件是否有效.
in below code i validEmail(readText[i]) method check emails are valid or not.
for (int i = 1; i < readText.Length; i++)
{
if (validEmail(readText[i])) // check valid
{
badEmail[] = readText[i];
m++;
}
}
如果电子邮件不正确,我希望在badEmail []中发送它
如果
电子邮件很好,我想要用goodEnail []
预先我不知道有多少坏邮件,所以我该怎么办?
请给我解决方法
if email is bad, i wants it in badEmail[]
and if
email is good i want it in goodEnail[]
In advance i dont know how many bad emails so how i can do?
please give me solution
Thanks.
推荐答案
List<string> badEmail = new List<string>();
List<string> goodEmail = new List<string>();
for (int i = 1; i < readText.Length; i++)
{
if (validEmail(readText[i])) // check valid
{
badEmail.Add(readText[i]); // Are you sure this should be a bad email?
m++; // the method name validEmail, would seem
} // indicate that it's a "good" email.
}
Dim goodemails() As String = (From email As String In readText Where validEmail(email) Select email).toArray
Dim bademails() As String = (From email As String In readText Where Not validEmail(email) Select email).toArray
这篇关于如何在C Sharp中的字符串数组中添加字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!