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...
Last week I was faced with a problem. I needed to implement a MouseDoubleClick Event on a WPF Grid. I said Ha, easy but as i went on to implement it i realized that the Grid has no MouseDoubleClick Event! So how am I supposed to implement it? I came up with 2 solutions and so here goes:
-
the first thought i had was to create a User Control that held only a grid and implement the MouseDoubleClick on the User Control itself so what you will get is this Xaml code:
<UserControl x:Class=”CustomDoubleClick.GridWrapper”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Height=”300″ Width=”300″>
<Grid>
</Grid>
</UserControl>
Since the Grid takes the…
Continue Reading...
List<T>.Find() returns the first element found that matches a given criteria. So lets say we have List<int> and we use the Find method on it. What will be the returned value? If a number in the list matches the criteria it will be returned, but what if not? what does the variable zero contains after executing this code:
List<int> listOfInts = new List<int>(new int[] { 1,2,3,4,5,6,7,8,9});
int zero = listOfInts.Find(
delegate(int i)
{
return i == 0;
});
It has the value of…
Continue Reading...
This post is third in the series of programming job interview challenge, if you are not yet familiar with these series please take your time and read:
- A Programming Job Interview Challenge
- A Programming Job Interview Challenge #2
Well, last weeks challenge was very successful, all of the comments which contain answers to the question are now approved and can be viewed in challenge #2 post.
Continue Reading...
Here is a list of 6 Visual Studio tweaks you can do to make your development experience much better:
Show shortcut keys in screen tips:
Go to Tools->Customize and choose the Toolbars Tab. This screen pops up-

Continue Reading...
ASP.NET provides mechanisms for storing information for a single user session or across multiple sessions. This is done using the HttpSessionState and HttpApplicationState classes. The Page class has Application and Session attributes to provide access to current objects. The simple way to access them is as following:
if (Session["FirstName"] == null)
{
LabelFirstName.Text = “FirstName”;
}
else
{
LabelFirstName.Text = (string)Session["FirstName"];
}
if (Session["LastName"] == null)
{
LabelLastName.Text = “LastName”;
}
else
{
LabelLastName.Text = (string)Session["LastName"];
}
Continue Reading...
Last week I posted A Programming Job Interview Challenge which was very successful, both in the amount of page views and, in the amount of comments and mails we received. This fact made us (the Dev102 team) decide to add a weekly programming job interview challenge column to www.Dev102.com.
Continue Reading...
Usually, we use Array.BinarySearch to find a value in a sorted array, we all know that this method returns the index of the searched value in the array, if value is found. It turns out that the return value of BinarySearch is much more interesting and useful. Lets focus on what happens if the value is not found in the array.
Those who claim that if value is not found than a negative number will be returned, are absolutely right. But most of us don’t really know the whole truth about that negative number and how it can be used.

Continue Reading...
Linq to xml provides an easy query interface for XML files. In the following example I will demonstrate how to use it for reading and writing data from/to xml file, using the file for persistency maintaining a list of objects. This can be used for storing application settings, storing persistent objects or any other data [...]
Continue Reading...
XPath is a language for addressing parts of an XML document, for those who are not familiar with this language - here are the W3C specifications and here is the W3schools tutorial. Now that we know XPath, lets get to the point of that post which is - Visual XPath.
This is a free graphical XPath [...]
Continue Reading...