I have to remove duplicate rows in a array using id using C#. In the array I have 3 columns.
Following is my code
[WebMethod]
public static string GetYesterdayPatientsByTime()
{
try
{
BusinessLogicLayer bal = new BusinessLogicLayer();
DataSet ds = bal.GetYesterdayPatientsByTimeBAL();
string[] output = new string[(ds.Tables[0].Rows.Count * ds.Tables[0].Columns.Count)];
int count = 0;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
output[count++] = ds.Tables[0].Rows[i].ItemArray[j].ToString();
}
}
JavaScriptSerializer js = new JavaScriptSerializer();
js.MaxJsonLength = 2147483644;
return js.Serialize(output.Distinct().ToArray());
}
catch (Exception)
{
return "";
throw;
}
}