May 2005 - Posts

Not of System.Object

When we learn C# we assume for all types the following holds true.

object o = <variable>;

So come to think of it is there any type that would not satisfy this statement (WRT to C#).
Well and here is a sample that shows you that there is a type who does not have
System.Object as its root, its the pointer.

class Class1
{
	public static void Main()
	{
		unsafe
		{
			int* variable;
			object o = variable;
		}
	}
}

Check out the compiler error you end up with :)

with 0 Comments

new int();

Whats the difference between ?

int i= new int();
int j=0;


If you check out the IL it turns out that there is no difference :)

  .locals ([0] int32 i, [1] int32 j)
  IL_0000:  ldc.i4.0
  IL_0001:  stloc.0
  IL_0002:  ldc.i4.0
  IL_0003:  stloc.1

with 0 Comments

Tasks TODO: Visual Studio

I guess that we all want to keep track of many things that we
do and still end up not organizing these. Ever tried writing code like this?

//TODO: remove intilialization
for(int i=0;i<a.Length;i++)
{
  a = new object
[i];
  Console.WriteLine(i);
}

Go to the task window (CTRL+ALT+K) and right click in this window and select
Show Task -> All
If you are more interested check out the taskList options in the

Tools->Options in visual studio
 


 

with 0 Comments