StringBuilder str = new StringBuilder(); var res = new ResParameter() { code = ResponseCode.exception }; var result = from isbn in dt.AsEnumerable() group isbn by isbn.Field<string>("isbn") into grp where grp.Count() > 1 select grp.Key; if (result.Count() > 0) { foreach (var item in result) { str.Append(item + ", "); } res.info ="導入EXCEL中包含重復ISBN' "+ str.ToString()+"' 請整理后再重新導入"; return res; }