Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Guest Post
Posted by Shahar Y on Oct 16th, 2008 | Filed under .Net, C# | 8 Comments

namingCollision

Are you familiar with the following C# compilation error: “CS0104: ClassA is an ambiguous reference between Namespace1.ClassA and Namespace2.ClassA“? It happens when your program contains using directives for two namespaces and your code references a name that appears in both namespaces.

Lets work with a concrete example:


Continue Reading...
Posted by Amit on Jul 31st, 2008 | Filed under .Net, C# | 22 Comments

Have you ever tried using  the "Using" statement with a method and not a class?

We all have done the following:

   1: using(StreamReader s = new StreamReader(@"c:\Test.txt"))
   2: {
   3:     // Do stuff
   4: }

Whether you know it or not, the compiler translates that code to the following:


Continue Reading...