Format:
Recent snippets matching tags of Lambda
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!");
67 Views
1 comments
private void Test() { List<string> messages = new List<string>(); messages.Add("Hello"); messages.Add("world"); messages.Add("!"); // Vroegah foreach (var msg in messages) Echo(msg);
85 Views
no comments
// 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();
68 Views
no comments
var _Offspring = _Context.Users
.SelectMany(x => x.Offspring).Distinct();
173 Views
no comments
[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()
83 Views
no comments
/// <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)
80 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
