Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Write for Dev102
Posted by Amit on Jul 31st, 2008 | Filed under .Net, C# | 22 Comments

Have you ever tried using  the "Using" statement with a method and not a class?

We all have done the following:

   1: using(StreamReader s = new StreamReader(@"c:\Test.txt"))
   2: {
   3:     // Do stuff
   4: }

Whether you know it or not, the compiler translates that code to the following:


Continue Reading...
Posted by Amit on Jul 30th, 2008 | Filed under Technology & Internet | 8 Comments

Here is a short tutorial about how to track Any Link Click with Google Analytics.

The first thing you will have to do is add a short snippet of code to the link you want to track. The code snippet you are adding is actually an OnClick JavaScript event handler that will be executed when the link is clicked and make Google Analytics take note of it. What you have to add is this the following:


Continue Reading...
Posted by Amit on Jul 29th, 2008 | Filed under C# | Leave a Comment

Hi All
We are sorry but wont be able to publish the job interview question today. We hope to publish it later on this week.
Sorry about that
Amit


Continue Reading...
Posted by Amit on Jul 29th, 2008 | Filed under .Net, WPF | 8 Comments

Have you ever tried to create a DataTemplate for a Generic Class? During last week I had to battle this issue and it is allot more complicated then it sounds. As far as I can tell Creating DataTemplates for Generic classes is impossible. There is some kind of workaround but it is not all that good. OK lets get down to business. This is the class we are trying to template

   1: public class GenericClass<T>
   2: {
   3:     private T m_Val;
   4:  
   5:     public T Val
   6:     {
   7:         get { return m_Val; }
   8:         set { m_Val = value; }
   9:     }
  10: }


Continue Reading...
Posted by Shahar Y on Jul 24th, 2008 | Filed under .Net, C#, Visual Studio | 2 Comments

Sometimes we are using the same patterns of code over and over again. Those of us who are lazy (but smart) will create their own code snippets, if you are not familiar with this subject, read about how to create code snippets easily. But what if we need to create lots of classes with the same pattern? Code snippets may not be enough because they lack of some functionality which is needed to achieve our goal. Consider the following code:

abstract class FourWheelsVehicle : IVehicle
{
    abstract public double MaxVelocity { get; }

    abstract public string Manufacturer { get; }

    abstract public double Price { get; }

    abstract public int YearManufactured { get; }

    virtual public int NumberOfWheels
    {
        get { return 4; }
    }
}

An abstract class called FourWheelsVehicle implements the IVehicle interface (which is not presented here because it is not important for our matter). Our task is to create classes which represent each and every existing 4 wheels vehicle, there is a lot of work to do, a huge amount of work. So, I started by implementing Mazda6 class:


Continue Reading...
Posted by Amit on Jul 22nd, 2008 | Filed under ASP.Net, Visual Studio | 7 Comments

Here is something nice I have found while wandering around the Internet. We all know jQuery, jQuery is a Framework written in JavaScript which makes client side and DOM work much easier and faster. If you don’t know it yet, be sure to check it out, it makes Web Developers life easy on the web. Shahar wrote a great article about Calling ASP.NET WebMethod with jQuery so check it out.


Continue Reading...
Posted by Shahar Y on Jul 21st, 2008 | Filed under .Net, Unmanaged Code | 89 Comments

The thirteen post of the series of programming job interview challenge is out, Only 13 comments with answers were provided to job interview challenge #12. This is a small amount comparing to the previous challenges, but I realize and understand that it was language specific and not very trivial challenge…

Jason Kikel was the first one to solve the question, and here is his short answer:

UnmanagedClass is referencing an address on ManagedClass without pinning it. The ManagedClass instance needs to be pinned so the GC won’t move it to another location during a collection.


Continue Reading...
Posted by Amit on Jul 18th, 2008 | Filed under Technology & Internet, Web Development | 2 Comments

Today, in many applications there is a need to know and use HTML. And if you are a Web applications programmer you probably should know HTML :).

The question is do you know all the HTML tags? Do you know exactly how they work and what each tag does? And the most important of all, how each tag acts in each browser?

There are hundreds of books, articles, WebSites, posts, blogs and manuals that claim to "teach" you HTML. I on the other hand think that there is no experience like hands on experience so I wanted to introduce you to HTML Playground . This is one of my favorites sites for HTML.


Continue Reading...
Posted by Amit on Jul 17th, 2008 | Filed under WPF | 15 Comments

Hi all

As you all remember in my article about Custom WPF Context Menu I mentioned that my WPF Binding Converter was a singleton, and I promised to tell you why, so here comes the 3 ways I know of using WPF Binding Converters. We will start from the worst (in my opinion) and move on the the best.

To start off here is the Binding Converter:


Continue Reading...
Posted by Shahar Y on Jul 16th, 2008 | Filed under .Net, C#, Unmanaged Code | 30 Comments

A week or two ago, I read an interesting article in Coding Horror called The Problem With Code Folding. Let me quote the beginning of this post:

When you join a team, it’s important to bend your preferences a little to accommodate the generally accepted coding practices of that team. Not everyone has to agree on every miniscule detail of the code, of course, but it’s a good idea to discuss it with your team and decide on overall approaches and philosophy beforehand. It promotes team harmony, and more than that, it’s just common courtesy. As they say, when in Rome, do as the Romans do. 

Jeff Atwood is talking about the fact that it is important to obey the coding conventions and practices of your team. Every one of us as its own preferences but as a team we need to have some rules, we all should work with the team, not against it. I must admit that I totally agree with Jeff’s attitude, no questions about it.

But, in addition to what was said before, Jeff continues:

Still, there are some coding preferences people may feel.. strongly.. about. If that’s the case, try to clear the air and address those strong preferences up front, as early as possible. Don’t let them simmer. For me, the use of #region is one of those things. I tried to make myself clear in this twitter message: No, I will not use #regions. And no, I DO NOT NEGOTIATE WITH TERRORISTS. Shut up.

I am not going to talk about the #regions issue, but to have my own say about another coding preference:


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