-1
我得到這個錯誤:GetExtension方法錯誤
would not find a GetExtension method
代碼:
public static void Main()
{
string[] arr = {"abc.txt", "asd.TXT","bvc.pdf","fgd.txt","hss.pdf","djhd.xml"};
var arrp = arr.Select(file=>Path.GetExtension(file).TrimStart('.').ToLower()).GroupBy(x=>x,(ext,extcnt)=>new
{
Extension = ext,
count=extcnt.Count()
});
foreach(var v in arrp)
{
Console.WriteLine("{0} files(s) with {1} Extension", v.Count,v.Extension);
Console.ReadLine();
}
}
我怎樣才能解決呢?
你加'System.IO'到您的項目? –
你的班級有沒有機會叫'Path'?請發佈[mcve]。 (這也不清楚這與ASP.NET有什麼關係。) –
事實上,正如其他人所說...嘗試System.IO.Path.GetExtension –