CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of compare
C#
/// <summary>
/// Add in item to a collection if it does not contain the specified element by using a IEqualityComparer<>. 
/// </summary>
/// <typeparam name="T">Type of the items in a collection</typeparam>
/// <param name="collection">The collection to add  the item</param>
/// <param name="item">The item to add to the collection</param>
/// <param name="comparer">An equality comparer to compare values.</param>
/// <returns>true if the item was added to the collection; otherwise, false.</returns>
public static bool Add<T>(this ICollection<T> collection, T item, IEqualityComparer<T> comparer)
{
by brentj   February 18, 2011 @ 7:26am
150 Views
no comments
 
C#
public static void Copy(string sourceDirName, string destDirName, bool excludeSubdirectories)
{
    // Style #1: fluent
    Guard.MethodArgument("sourceDirName").IsNotNullOrEmpty(sourceDirName);
    Guard.MethodArgument("destDirName").IsNotNullOrEmpty(destDirName, "The destination directory is required!");
 
    // Style #2: lambdas and expressions
    Guard.Argument.IsNotNullOrWhiteSpace(()=>sourceDirName);
    Guard.Argument.IsNotNullOrWhiteSpace(()=>destDirName, "The destination directory is required!");
by Al Gonzalez   May 24, 2010 @ 8:58pm
309 Views
1 comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate