Sunday, March 1, 2009

C# Class Indexors

Pretty cool feature of C#, for a newbie this is awesome unlike PHP. Say you have 4 class properties

class blah
{
string freddy;
string dafney;
string cave;
string flintstones;
}

And you declared it like:

blah mycartoon;
mycartoon = new blah();

If I wanted to access my classes I wouldn't use a period then the property like:

mycartoon.flintstones;

I can do:

mycartoon[3];

Pretty cool right?

Have fun learning C#

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