2016-11-11 118 views
1

我試圖讓下面的代碼在ubuntu linux上運行的dotnet核心工作 - 但得到一個「字符串不包含複製的定義」編譯錯誤在這一行 - 顯然dotnet-core不支持String.Copy:dotnet核心的String.Copy替代

  Attendance = String.Copy(markers) }; 

在dotnet Core中執行淺色字符串複製的最佳方法是什麼?我應該使用string.CopyTo?

感謝

//I want to add an initial marker to each record 
//based on the number of dates specified 
//I want the lowest overhead when creating a string for each record 

string markers = string.Join("", dates.Select(p => 'U').ToArray()); 
return logs.Aggregate(new List<MonthlyAttendanceReportRow>(), (rows, log) => { 
    var match = rows.FirstOrDefault(p => p.EmployeeNo == log.EmployeeNo); 
    if (match == null) { 
     match = new MonthlyAttendanceReportRow() { 
      EmployeeNo = log.EmployeeNo, 
      Name = log.FirstName + " " + log.LastName, 
      Attendance = String.Copy(markers) }; 
     rows.Add(match); 
    } else { 
    } 
    return rows; 
}); 
+0

可能的重複[如何在.net核心的String.Copy?](http://stackoverflow.com/q/41758338/213550) – VMAtm

+0

類似的問題是的,但這一個被問了2個月前另一個?不知道如何處理這個。 – onemorecupofcoffee

+0

是的,看起來這個問題得到了更少的嘗試,我的壞:( – VMAtm

回答

1

試試這個:

string b = "bbb"; 
var a = new String(b.ToArray()); 
Console.WriteLine("Values are equal: {0}\n\nReferences are equal: {1}.", Object.Equals(a,b), Object.ReferenceEquals(a,b)); 

你可以看到它在this fiddle運行。