没有合适的资源?快使用搜索试试~ 我知道了~
在C#中当索引字符串为空时,删除此索引,并从新排列索引
资源推荐
资源详情
资源评论
/// <summary>
/// 当索引字符串为空时,删除此索引
/// </summary>
/// <param name="strs"></param>
/// <returns></returns>
public string[] deleteNullstring(string[] strs)
{
lock (this)
{
List<string> stringList = new List<string>();
string[] newstrs;
int nullstrNum = 0;//记录有多少个不是空字符串的索引个数
for (int i = 0; i < strs.Length; i++)
{
string isnull = strs[i];
if (isnull != "" && isnull != null)
{
nullstrNum++;
stringList.Add(isnull);
}
}
newstrs = new string[nullstrNum];
int listIndex = 0;
foreach (string list in stringList)
{
newstrs[listIndex] = list;
listIndex++;
}
return newstrs;
}
/// 当索引字符串为空时,删除此索引
/// </summary>
/// <param name="strs"></param>
/// <returns></returns>
public string[] deleteNullstring(string[] strs)
{
lock (this)
{
List<string> stringList = new List<string>();
string[] newstrs;
int nullstrNum = 0;//记录有多少个不是空字符串的索引个数
for (int i = 0; i < strs.Length; i++)
{
string isnull = strs[i];
if (isnull != "" && isnull != null)
{
nullstrNum++;
stringList.Add(isnull);
}
}
newstrs = new string[nullstrNum];
int listIndex = 0;
foreach (string list in stringList)
{
newstrs[listIndex] = list;
listIndex++;
}
return newstrs;
}
资源评论
haohaojiejie2
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功