小编Cla*_*ude的帖子

如何检查C#中是否存在列表索引?

我有以下代码片段:

public static List<string> sqlData = new List<string>();

//
//  lots of code here
//

if (/* check here to see if the sqlData[whatever] index exists  */)
{
    sqlData.Insert(count2, sqlformatted);
}
else
{
    sqlData.Insert(count2, sqlformatted + sqlData[count2]);
}
Run Code Online (Sandbox Code Playgroud)

我想知道的是如何在尝试插入包含自身的东西之前检查sqlData上的索引以查看它是否存在.

c# list

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

list ×1