Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Write for Dev102
Posted by Shahar Y on Nov 10th, 2008 | Filed under .Net, C# | 2 Comments

shootinfoot

There are several things a software developer can do to make his life much more difficult in the future. One day, some pieces of an old code may make us sorry we haven’t dedicated some more effort when we wrote it, so we have to pay attention and be careful. I am not talking about bad developers who always generate bad code because in those cases, every piece of their code is a disaster. Amit is talking about this issue in Terrible Code Examples - Methods From Hell. In this article I will point out some more .NET advanced issues that even the best developers have to be aware of. There are some things you can do which will cause some problems later on and you will be the one who have to handle with those issues. In other words, I will try to prevent you from shooting yourself in the foot.


Continue Reading...
Posted by Shahar Y on Jul 8th, 2008 | Filed under .Net, C# | 8 Comments

This one could be easily become one of the Job Interview Questions we publish here at Dev102.com, but I decided to write a “regular” post about this issue because it is an important concept and not a just a puzzle or a brain teaser. Take a look at the following code, can you tell what will the output be?

public class BaseType
 {
     public BaseType()
     {
         Console.WriteLine("Call base ctor.");
         DoSomething();
     }

     public virtual void DoSomething()
     {
         Console.WriteLine("Base DoSomething");
     }
 }

 public class DerivedType : BaseType
 {
     public DerivedType()
     {
         Console.WriteLine("Call derived ctor.");
     }

     public override void DoSomething()
     {
         Console.WriteLine("Derived DoSomething");
     }
 }

 public class MainClass
 {
     public static void Main()
     {
         DerivedType derived = new DerivedType();
         Console.ReadLine();
     }
 }

The output of this program is:


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