Posts

Showing posts from April, 2013

Productivity: Two command-prompt time savers

Image
Recently while watching pluralsight.com videos I noticed that the authors use a console window which allowed them to select and copy text using mouse. And they also had auto-completion for files/directories. As a developer, we work a lot with console applications now and then and having these two features should be a huge time saver.

1> Text selection, copy and paste

Normally we have to click Edit –> Mark –>  Select text –> Press Enter, but there is a quicker way!

- Right-click the title bar and click Properties.



- In the Options tab, look for “Quick Edit Mode” and enable it.
With this setting, we can use left-button mouse to select text and then right-button click or ENTER to copy it. And to paste something, we can click right-button.





2> Auto-completion for files/directories:
For the auto-completion we need to modify the registry. The steps are:
- Open regedit.exe
- Look for HKEY_CURRENT_USER\Software\Microsoft\Command Processor
- Change the value of CompletionChar to 9.







On my co…

C#: object, var and dynamic

Image
One of the interesting concept introduced in C# 4 was the “dynamic” keyword. Let’s see how it is different from the “var” or our old friend “object”.

1. System.Object has been with us since the birth of .NET framework. It is the base class of almost everything. It means we can write:

1: object ostring ="Hello"; 2: object oint =555; 3: oint ="Hello int"; //point to a string 4: ostring =-100;//point to an int
Usage: It is used when the type could be anything. For example a method using object parameter to accept any type and then casting it to appropriate type or use reflection to call operations; or a collection which can hold any type. However with the advent of generics ‘object’ is used less often when creating collections. The primary goal of object class is to be a base class and offer low-level services, which include methods which are common to almost every type in .NET framework or created by users. Methods like ToString(), Equals(), GetHa…