By tag: lambda
0
kicks
C# 101: Delegates and Lambdas
The purpose of this article is to demystify delegates and help you gain some understanding about how different ways of using delegates relate to each other.
0
kicks
Getting Started with LINQ - Part 2 (Language Enhancements)
In my previous post I summarized Microsoft Language Integrated Query (LINQ). Briefly discussed about its components as well as showed some code examples to highlight the sql query type syntax it uses. When we talk about LINQ, we are talking about number of little features that were added in .net 3.0...
0
kicks
Getting Started with LINQ
In this we’ll continue to discuss how to go about the SQL Server Data Access using various technologies. This post will discuss Microsoft Language Integrated Query, otherwise known as LINQ. I will discuss how it can be used to accomplish the same tasks we have discussed in previous posts. But before...
0
kicks
Beef up params in C# 5 to solve Lambda Abuse
C# 4 introduced named and optional method parameters, which does a fine job of cleaning up method overloads. But a piece of the puzzle was left out. The params keyword could have been combined with named parameters to make it even stronger and address issues others have overcome by abusing other lan...
0
kicks
GroupBy and Average with Lambda Expressions
I was recently tasked with generating a string of averages based on a list of business objects. The business object has a string property called VehicleName and a decimal property called StandardMpg. The averages needed to be calculated per VehicleName, so this is to be what I group on.
0
kicks
Stretching Lambda’s Legs: Single Statement String Concatenation
So let’s get started, supposing you wish to compile a list of song titles separated by a comma, ordinarily you would for each loop them, then assign the comma as “, “ on the second iteration. Well, I wanted to get tricky of course...
0
kicks
System.Linq.Enumerable.All - Better Know an Extension Method Part 2
Learn how to harness the power of "All" a powerful new extension method brought to you by System.Linq
0
kicks
System.Linq.Enumerable.Aggregate - Better Know an Extension Method Par
Learn how to harness the power of Aggregate a powerful new extension method brought to you by System.Linq
0
kicks
When would you use delegates in C#?
This is a valid question. Before C# 3.0, you could use delegates or declare full methods to bind to events. Now we can declare event directly through lambda. Delegates is a keyword that can be used to declare inline methods. This inline code can be stored inside variables and then executed when nece...
0
kicks
Sweet lambda trick to append to MVC SelectList()
Well I was thinking of an ill-tricky way to append a string to the beginning of each list item in ASP.NET MVC’s SelectList collection, tell me if this might help you...
0
kicks
Code Snippet: Filtering a list using Lambda without a loop
Quick code snippet to remove some loops inside your code and increase visibility inside your methods.
0
kicks
Creating a StreamProxy with Delegate/Lambda to read/write to a file
I was once asked "What is the use of a delegate?". The main answer that I found was "to delay the call". Most people see delegate as events most of the time. However, they can be put to much greater use. Here is an example that I'll gladly share with you all.
0
kicks
Custom logic in C# automatic properties
The article tries to make an argument in favor of having support for introducing custom-logic with automatic properties in C#. It also shows a possible solution and asks for ideas for refinement.
0
kicks
Avoiding Inheritance Dependencies Using Generics and Lambdas
A nice implementation of the Command pattern using generics and lambdas
0
kicks
C# methods decoration using lambda expressions
On regular basis several repeating code blocks appear in projects source code. Wouldn't it be great if we could just say: here is my method, do call within TCF block ("try - catch - finally" block) first time I need it, but I may require to call it with "try - catch" block only n...