C# Building an SQL list

Date: 2016-03-19
public static string GetSqlList(IEnumerable list)
{
	StringBuilder sb = new StringBuilder();

	foreach (T item in list)
	{
		if (item != null && item.ToString() != "")
		{
			if (sb.Length != 0)
				sb.Append(", ");
			sb.Append("'");
			sb.Append(item.ToString().Replace("'", "''"));
			sb.Append("'");
		}
	}
	return sb.ToString();
}
1150cookie-checkC# Building an SQL list