有没有办法使一个对象中的逗号分隔开。请注意,这是对象而不是对象列表。
例如:
public class EmployeeLogReportListViewModel
{
public DateTime Date { get; set; }
public int EmployeeID { get; set; }
public TimeSpan Time { get; set; }
public int Sort { get; set; }
public string Employer { get; set; }
}
以下是相关数值
Date = "2018/02/03"
EmployeeID = 111
Time = 11:53 AM
Sort = 1
Employer = EMP
这应该导致的结果是:
2018/02/03,111,11:53 AM,1 EMP
什么是使这行代码成为可能的最佳方法?我不想使用string builder并将所有内容附加到它上面。