Monday, March 17, 2008

C# indexer

Declaration:
public this [ identifier]

Example:
public string this [int theIndex]



Sample C# Use:

using System;

//Indexer Class Declaration
class MyIntIndexer
{
private string[] theData;

public MyIntIndexer(int size)
{
theData= new string[size];

//Initialize
for (int i=0; i < size; i++)
{
theData[i] = "nothing";
}
}

public string this[int position]
{
get
{
return theData[position];
}
set
{
theData[position] = value;
}
}


static void Main(string[] args)
{
int size = 5;

MyIntIndexer myIndexer = new MyIntIndexer(size);

myIndexer[3] = "str3";
myIndexer[1] = "str1";
myIndexer[5] = "str5";

}
}

Monday, March 10, 2008

const vs readonly

a const member's value is defined at compile time.
a readonly member's value can be set at runtime as well as compile time.

static means the member is not tied to the instances of the class. There exists only one copy of the static member regardless of the number of instances.

Thursday, December 27, 2007

Design Patterns

Creational:

Abstract Factory: Creates concrete instances of classes.

Singleton:
Creates a single instance of a class and ensures there is only one instance in the system.
Class contruction: Keep a private member in the class and let the constructor initialize it only if that member is null.
Application: System resources; there is only one printer in the system and we must access it thru singleton pattern.

Structural:

Facade: Represents an entire system of subclasses.

Proxy: Not the real object itself, just represents the real object.

Behavioral:

Command:
A command request is encapsulated as an object.

Observer:
Notifies changes to classes.
Application: Error logging.

Web Design specific:

MVC (Model-View-Controller):

Complete separation of the;
model (database),
view (page view) and
controller (business logic).

Thursday, November 29, 2007

.NET Framework 3.5 Released!!

As most of the .NETers know, Microsoft .NET Framework 3.0 has been in the market for a while.
Along with that .NET Framework 3.5 was also available as a Beta version and as of 19th of November 2007, .NET Framework's 3.5 version has officially been released!
A new toy for us programmers to play around isn't it?! :)
So with this version it's been about two years know after .NET Framework 2.0' release in 2005.

Here are the direct links to download from Microsoft - for those who wanna skip to the download right away!
Download Microsoft .NET Framework 3.5

I'd suggest to download the express version of Visual Web Developer 2008 along with the new framework:
Download Visual Web Developer 2008 Express
Download Visual C# 2008 Express

Find the rest of the 2008 Express Series by clicking here.

I played around little bit with the VWD 2008 Express. Three things that came to my sudden interest:

  1. Microsoft's recent popular keywords: Controls for AJAX, Silverlight & LINQ are available in the toolbox.
  2. CSS Properties & Manage Styles tabs saying "hello!" from the left border of the VWD.
  3. "Split" design mode in addition to 'HTML' and normal 'Design' mode. Was available in Frontpage. Good to see it now in VWD or Visual Studio let's say for those who are lucky to start developing in the 2008 version of Visual Studio! :)

Will keep sharing my experiences with .NET Framework 3.5 and Visual Web Developer!

Please gimme your comments on this and make me happy :)