Skip to content

Instantly share code, notes, and snippets.

@inoto
Created November 7, 2017 06:36
Show Gist options
  • Save inoto/5625e5c0345ec4d08a310f1a77db3e3c to your computer and use it in GitHub Desktop.
Save inoto/5625e5c0345ec4d08a310f1a77db3e3c to your computer and use it in GitHub Desktop.
Extension methods example
namespace SampleNS
{
public static class CommonUtil
{
public static string ListToString(this IList list)
{
StringBuilder result = new StringBuilder("");
if (list.Count > 0)
{
result.Append(list[0].ToString());
for (int i = 1; i < list.Count; i++)
result.AppendFormat(", {0}", list[i].ToString());
}
return result.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment