日期:2014-05-17 浏览次数:20430 次
private int[] RepalceArray(int[] values, int pos, int oldvalue, int newvalue) { values[values.Select((a, i) => new { i, a }).Where(a => a.a.Equals(oldvalue)).Take(pos).Reverse().FirstOrDefault().i] = newvalue; return values; }
------解决方案--------------------
string oldarr = "1,2,3,4,5,5,6,7,4,3"; int arrnum = 3; string newstr = "5"; string[] parts = oldarr.Split(','); parts[arrnum] = newstr; string r = string.Join(",", parts); Response.Write(r);