By tag: Delegate
0
kicks
Using Async Delegates instead of the Thread class
If you want to write some asnychronous code, the good old fashioned way is to create a new Thread. But this has several pitfalls, e.g. when you need to use parameters or you need to retrieve a return value. Then this way is getting tricky.
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
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
Create elegant code with Action delegate and List.ForEach method
Small example of how to use Action delegate to perform some action on all elements of a collection.
0
kicks
C#: Care about Event Memory Leaks with Delegate.GetInvocationList()
Subscribed events are one of the most common reasons of memory leaks in .Net. This means that if you have an object that has an event and there are other object that are subscribed to that event, the original object won't be properly disposed until all events are unsubscribed since an event is a st...
0
kicks
The Power of the Predicate<T>
The very flexible generic collection List<T> contains several methods that take a predicate as it's parameter. Coupled with Anonymous Methods this provides powerfully concise code for filtering, searching and sorting your collections.
0
kicks
The Action Delegate
Did you know that by using the Action delegate we can define a single operation which will automatically be applied to every member of an array?
This is a great way to make your code cleaner and more elegant,
0
kicks
Managing collections with functors
An easy way of working with collections using the new features of C# 2.0.