Saturday, February 28, 2009

C# Changing Types the correct way

C# is simple, but changing variable types might get people confused. Heres the illegal way to change variable types:

Incorrect Way

int x;
long value = 10;
x = value;

Correct Way

int x;
long value = 10;
x = (int) value;

Have Fun

C# Testing Applications without publishing

Alright, it took me a while but I finally figured out how to do this.
  1. Visual C# 08 go to Build => Build Solution
This is called Build -> Build "Project Name" in 2005

Or you can press F6 in VC# 2008 Express Edition

C# Enabling Auto Completion Property Drop Down

Here is what you do when the auto complete drop down doesn't show.

  1. Hold CTRL + Space
And it should popup. It's that simple.

C# Refactor Menu Tip

Always use the refactor menu tip when renaming event classes to help debugging in the future.

Steps:
  1. Go to Menu
  2. Select Refactor
  3. Select Rename
  4. Enter method name
  5. Press Enter Twice
Or

  1. Press F2
Reasons Why you should use refactor menu to rename functions:
  1. Safest way to make changes to code
  2. Could cause reference debug errors when something elsewhere is trying to reference that function