How to get a raise

Once upon a time I was dissatisfied with my salary at my workplace, and I let it show. The boss, fearing that he was about to lose me, placed an ad in the newspaper for my exact job description. Since I was looking for a job, I saw the ad in the newspaper. What I did was to reply to that ad, sending my boss my resume, which of course included precisely those qualifications that the job required. The boss got the message.

C# Blooper №4: Lame/annoying variable scoping rules, Part 1

Before reading any further, please read the disclaimer.

A variable identifier is, of course, only visible within the scope in which it is declared. This includes nested (child) scopes, but it does not include enclosing (parent) scopes. In C# however, once a variable identifier has been used in a scope, its name is “poisoned”, so it cannot be used in enclosing scopes. Take this example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
namespace Test4
{
    class Test
    {
        void test()
        {
            if( this != null )
            {
                object o;
                o = null;
                if( o == this )
                    return;
            }
            object o;  //error CS0136: A local variable named 'o' cannot be declared in this scope because it would give a different meaning to 'o', which is already used in a 'child' scope to denote something else
        }
    }
}

Well, I am sorry, but in the above case the new variable named ‘o’ would most definitely *not* give a different meaning to the ‘o’ which was used in the child scope. It would, if it had been declared before the ‘if’ statement, but it wasn’t. Luckily, if this “feature” was to be removed from the language, it would not break any existing code. So, can we please have this fixed? Pretty please?

Read more »

C# Blooper №6: No warnings about unused parameters

Before reading any further, please read the disclaimer.

One common mistake that programmers make is to forget to make use of a parameter to a method. This can lead to quite subtle bugs that are hard to track down and correct.

Now, other language compilers are kind enough to warn the programmer that a parameter is unused, and they also allow temporary suppression of the warning for the rare case when such lack of use is legitimate. But not so in Visual C#. If you forget to use a parameter in Visual C#, you will not know unless you run the “Code Analysis” tool on it.

Read more »

C# Blooper №5: Lame/annoying variable scoping rules, Part 2

Before reading any further, please read the disclaimer.

In light of the previous blooper, this one is more of a confusing error message than an actual new blooper. What I am doing below is that I am declaring a field within a class, I am accessing that field from within a method, and further down within the same method I am declaring a new local variable with the same name as the field. Now, C# will not allow me to declare that local variable because it has the same name as the field, but that’s not where I am receiving the error. Instead, the error is given when accessing the field. If you only read the first sentence of the error message, it does not make any sense at all. If you bother also reading the second sentence, it gives you a hint as to the real problem. Now, that’s not very cool.

Read more »

How to copy multiple contacts from Outlook to Lync

I wanted to copy data from the Outlook contacts list to the Lync contacts list. I managed to do it. Here is how.

It is kind of amazing how crippled the co-operation is between Microsoft Outlook and Microsoft Lync. (Note: I am talking about Microsoft Office Professional Plus 2010, with Outlook version 14.0 32-bit and Lync 2010.) Never mind the fact that these two programs should be sharing the exact same contact list and I should not have to do anything of that sort; it sounds like a simple task, right? Copy contacts from one program to another. These two programs belong to the same Office suite and are supposedly seamlessly integrated with each other. Well, seamlessly my @$$. You can copy single contacts from Lync to Outlook. But if you want to copy a contact from Outlook to Lync, or copy multiple contacts, then you are completely out of luck. No-can-do, apparently.

Read more »

Scanning printed photos

I was looking around for advice on what settings are best for scanning printed photos and I was amazed by the number of answers floating around on the great interwebz which are misguided, or are technically correct but miss the point. So, here is my advice.

First of all, let us define the goal: For a home user to scan printed photos so as to retain as much as possible of the visual information contained in the print, within reasonable limits, and without wasting too much space.

Read more »