My best shot:
var result = SourceExcelTemplateCollection
.Select(x=>new
{
SourceExcelTemplateId = Path.GetFileNameWithoutExtension(x).Split('_')[1]
});
It should return
IEnumerable<string>
. To get an
array or a
list of string, use
ToArray()
or
ToList()
method at the end of above statement.
[EDIT]
I suspect that you want to achieve something like this:
string[] SourceExcelTemplateCollection = new string[]{@"C:\Template_C012.xslt",
@"C:\Template_D511.xslt",
@"C:\Template_H914.xslt",
@"C:\Template_A011.xslt"};
List<string> StdExcelTemplateIdList = SourceExcelTemplateCollection
.Select(x=>Path.GetFileNameWithoutExtension(x).Split('_')[1])
.ToList<string>();
Result:
C012
D511
H914
A011