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 lambda
C#
using System;
using System.Linq.Expressions;
 
public static class Aaa
{
    public class A
    {
        public string NameField;
    }
by b1gbr0   October 26, 2010 @ 3:30am
177 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
310 Views
1 comments
 
C#
// usage:
// var constructor = GetConstructor<Foo>();
// IFoo foo = constructor();
 
 
private static Func<T> GetConstructor<T>() where T : class, new()
{
    ConstructorInfo constructorInfo = typeof(T).GetConstructor(new Type[0]);
    return Expression.Lambda<Func<T>>(Expression.New(constructorInfo))
                .Compile();
by tarasn   March 26, 2010 @ 12:21pm
Tags: lambda
406 Views
no comments
 
C#
var _Offspring = _Context.Users   
        .SelectMany(x => x.Offspring).Distinct();
by Jerry Nixon   March 05, 2010 @ 8:44am
596 Views
no comments
 
C#
[TestMethod]
public void CanGetValueItemfromCollection()
{
    var col = new Collection<string> {"Hello", "World"};
    var testItem = col.GetValueItem(c => c.Equals("World"));
    Assert.AreEqual(testItem, "World");
}
 
[TestMethod]
public void CanGetReferenceItemfromCollectionByProperty()
by Bob Baker   December 18, 2009 @ 12:01pm
302 Views
no comments
 
C#
/// <summary>
/// Find an object in a value-type collection.
/// </summary>
/// <typeparam name="T">Type of collection.</typeparam>
/// <param name="collection">The collection to search.</param>
/// <param name="isMatch">The Predicate to test to find the collection item.</param>
/// <returns>The collection item.</returns>
public static T GetValueItem<T>(this ICollection<T> collection, Predicate<T> isMatch)
{
    foreach (var item in collection)
by Bob Baker   December 18, 2009 @ 12:00pm
280 Views
no 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