var result=list.select(element=>element.split['_']).list();
/* I want to extract the part of the file name from a list of file names */
我有一个文件名数组,我想从数组中提取每个文件名的部分名称
例子:
0-policy001_Printedlabel.pdf
1-policy002_Printedlabel.pdf
2-policy003_Printedlabel.pdf
3-policy004_Printedlabel.pdf
现在我想使用 Linq 从上面的数组中提取一个数组,它只给我
policy001,policy002,policy003,policy004
你能帮帮我吗?我是 lambda 表达式的新手。
最佳答案
List<string> output = fileList.Select(fileName => fileName.Split(new char[] {'-','_'})[1]).ToList()
关于c# - linq 和字符串数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13882024/