Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Write for Dev102
Posted by Amit on Dec 1st, 2008 | Filed under .Net, C#, WPF | 2 Comments

Hi

 

A while back I wrote an article about How to sort data by manipulating the view only, This article will handle filtering the data without changing it.

 

I had a large collection that I needed to display and allow the user to filter it using many parameters. After searching for a while I found a very elegant solution:

 

What is a Predicate

what are predicates? I will Quote

Represents the method that defines a set of criteria and determines whether the specified object meets those criteria.

You can read more about it here.

 

Defining a Predicate

A predicate Is a template so you will have to specify the type for instance:


Continue Reading...
Posted by Shahar Y on Sep 22nd, 2008 | Filed under .Net, C# | 7 Comments

Here is the code which defines a C# EventHandler, as written in the documentation, it represents the method that will handle an event that has no event data:

// Summary:
//     Represents the method that will handle an event that has no event data.
//
// Parameters:
//   sender:
//     The source of the event.
//
//   e:
//     An System.EventArgs that contains no event data.
[Serializable]
[ComVisible(true)]
public delegate void EventHandler(object sender, EventArgs e);

So after declaring a specific event:

private event EventHandler OnSomethingHappened;

We need to write a method to raise this event:


Continue Reading...
Posted by Shahar A on May 15th, 2008 | Filed under .Net, C# | 6 Comments

Did you ever need to convert List(T1) to List(T2)? One example might be when implementing an interface. you might need to expose a collection of other interfaces (or maybe the same interface), But you usually hold the concrete type implementing the interface in the collection. Lets look at the following example:


Continue Reading...
Write Article for Dev102

Write for Dev102!

We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution

Learn More