Created
November 7, 2017 06:36
-
-
Save inoto/5625e5c0345ec4d08a310f1a77db3e3c to your computer and use it in GitHub Desktop.
Extension methods example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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