Links:
view my trainer profile on TrainerExchange.com Listed on: Dmegs Web Directory

PHP video tutorials

phpmath.com
phpclasses.org
Canadian Mathematical Society
camel.math.ca

Algebra.com
Blogs:
rationalcode.com
Silverlight Playground

Technology:
silverlight.net
XNA Creators Club Online
php
asp.net


WCF 4.0 exam is to be published in July 2nd

by Administrator 28. June 2010 07:20

Finally the WCF 4.0 certification exam is being published in less than a week. (July 2nd as Microsoft promissed). You can check the following link for more detailed information:

http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-513&locale=en-us

Right now, there is no MS Press book to prepare for this exam but I truly like this book from Wrox. 

This MS course will be also availabe on late July if you can not wait for the book.  MCTs can use the course materials to prepare themselves for the exam. MCTs! Do not forget! There is a %65 off if you take this exam within 90 days of the publish date.

 Good luck! :)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.NET | .NET 4 | Training

IEqualityComparer interface: How to remove objects with the same property values from a generic list.

by Administrator 16. November 2009 04:45

Problem description:

Any developer is familiar with the concept of removing duplicate numbers from a list or array. .NET 3.5 offers the new extension method “Distinct” in System.Linq namespace which can be used to remove all duplicate integers(or any value type) from a list of numbers. Here is an example:

List<int> listOfNumbers = new List<int>() { 1, 5, 4, 10, 1, 4 };
List<int> uniqueList = listOfNumbers.Distinct().ToList<int>();

Distinct method is great. is not it?

Now imagin a list of a domain objects for instance a list of User object where the User has the following signature:

class User
 {
    public string Username;                
 }

User u1 = new User() {Username="nima" };
User u2 = new User() { Username = "reza" };
User u3 = new User() { Username = "nima" };
User u4 = new User() { Username = "sanam" };
List<User> listOfUsers = new List<User>() { u1, u2, u3, u4 }; 

The goal is to remove duplicated User objects with the same Username. Although u1 and u3 have the same Username, from the framework point of view they
are not equal because they have different hash codes. So how can we use the Distinct method? Here is where the IEqualityComparer<T> inteface comes to account.
To define the concept of equality for complex objects, we can create a class (UserComparer) which implements the IEqualityComparer<T> interface where T is our complex business type (User here).
In UserComparer class, we will specify under which circumstance two User objects can be considered equal. This interface has two methods which we need to implement:

  1. Equals
  2. GetHashCode

The class implementation follows:

public class UserComparer : IEqualityComparer<User>
{
    public bool Equals(User x, User y)
    {
       return x.Username == y.Username;
    }
    public int GetHashCode(User obj)
    {
       return obj.Username.GetHashCode();
    }
}

Now in the client code we can use this syntax to remove the duplicate usernames from our list:
List<User> uniqueListOfUsers = listOfUsers.Distinct<User>(new UserComparer()).ToList<User>();

So uniqueListOfUsers will only contain User objects with reza, nima and sanam Usernames.

For a detailed information please visit
http://msdn.microsoft.com/en-us/library/ms132151.aspx

Currently rated 3.7 by 3 people

  • Currently 3.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , , ,

.NET | Training

ASP.NET, Having items with different color in a ListBox or DropDownList

by Administrator 14. July 2009 02:41

One of my firends asked me "How can we change the text color for an individual item in a DropDownList or ListBox?". I thought it is a good idea to share the answer with you! The folowing image shows the dropDownList with the solution implemented. As you can see the First two items are red and the rest are black.

To implement it, follow these steps:

  1. Put a DropDownList control on your webform: <asp:DropDownList runat="server" Width="200" ID="lstAccounts" />
  2. On the Page_Load event handler add the following code
    1. // First items (Red)
      ListItem listItem1 = new ListItem("100000 (Active)", "100000");
      listItem1.Attributes.Add("style", "color: red;");
      lstAccounts.Items.Add(listItem1);
    2. // Second items (Red)
      ListItem listItem2 = new ListItem("100001 (Active)", "100000");
      listItem2.Attributes.Add("style", "color: red;");
      lstAccounts.Items.Add(listItem2);
    3. // Third items (Red)
      ListItem listItem3 = new ListItem("123456 (Active)", "100000");
      listItem3.Attributes.Add("style", "color: black;");
      lstAccounts.Items.Add(listItem3);
    4. // ...

You have also control over all attributes which are changable via CSS styles.

You can do the exact same thing with the ListBox object.

Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , ,

.NET | Training

Download the Microsoft Visual Studio® 2010 Beta

by Administrator 22. May 2009 06:23

Download the Microsoft Visual Studio® 2010 Beta from Microsoft.

As Microsoft says:

"It’s the next gen of next-gen applications. Download the Visual Studio 2010 Professional and Team System Betas and see for yourself how they’ve been designed inside and out to give you every advantage in creating groundbreaking applications — faster and easier than ever."

Enjoy!

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.NET | SilverLight 2.0 | TFS/MS BUILD

MS Build - The $(BuildDirectory) property.

by Administrator 22. May 2009 02:34

TFS uses MS-Build as the build engine. Ms-Build gets the code from TFS code repositiry and builds it in a temporary build location and copies the build result (binaries, web sites, etc...) to the permanent build output location refered as the DropLocation.

To customize my build project, I needed to have access to the temporary build location within in build definition and I finally found the $(BuildDirectory) property which does exactly I want.

During my search, I found Sayed Ibrahim Hashimi's blog with a list of  useful "MSBuild reserved properties".

You can also take a look at MSBuild Reserved Properties at Microsoft website.

Currently rated 3.5 by 2 people

  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.NET | TFS/MS BUILD

Creating MSDN Style Documentation Using SandCastle In TFS Project Build.

by Administrator 21. May 2009 07:17

Sand Castle is a Microsoft tool which can be used to generate MSDN style documentation for .NET assemblies. It can be integrated with the TFS project build to generate the CHM document after each successful build.

I found Anthony Steele's Blog extremly helpful in this matter.

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

.NET | TFS/MS BUILD | Training

.NET Magnet Painter

by Administrator 9. March 2009 15:27

I wrote this VB.NET application about two years ago. It simulates drawing with a magnet and iron filings. You can save your drawings in a text file and reload it later.

I developed this application with having electromagnetics concepts in mind so actual formulas are used to calculate the speed and direction of the filings.

The first step is defining the canvas. Here you set the width and height of the canvas and also the width and number of filings.

Then you have the canvas ready for you with loaded iron filings as follows:

You can adjust the magnet strength by clicking on the circles (buttons) on the top left. Darker circle means stronget magnet. At the end you can save your awesome painting and reload it again in future. You can download the executable here.

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

.NET | Algorithms and Data Structures | Physics

Fractal (Koch Curves) in SilverLight 2.0

by Administrator 9. March 2009 14:06

As a Flash and C# developer, I was always curious to try SilverLight so I read a book on SilverLight 2.0 and really enjoyed it. I tested my SilverLight knowledge by doing a "cool" application on fractals.

According to Wikipedia, A fractal is generally "a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole,"[1] a property called self-similarity.

You can try it here. In the first textbox, you need to enter the number of recursion levels. I don't recommand anything over 7. In the second textbox, you need to enter the size of the recursion in pixels. After setting these values, press the button.

IE should be used to try this demo and SilverLight 2.0 plugin must be installed.

Click to try it yourself

Currently rated 2.5 by 2 people

  • Currently 2.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

.NET | Algorithms and Data Structures | Mathematics | SilverLight 2.0

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

Reza Salehi
Microsoft Certified Professional

Microsoft Certified Trainer

Microsoft Certified Professional Developer

Microsoft certiied Technology Specialist (ASP.NET 2.0)

About Me

I started this blog to share my ideas, programs and interesting programming notes. Visitors who are interested in mathematics, physics and astronomy may find my blog interesting.

I live in Toronto, Canada and work as a Senior Software Developer and Microsoft Certified Trainer.

My online Microsoft web page is available  here.  Online business card.

RecentComments

Comment RSS