79602531

Date: 2025-05-01 21:11:53
Score: 0.5
Natty:
Report link

It depends on the usings - as the using declaration basically adds the namespace to all code in the file

  1. Console isn't dependent on your namespace so will work because of the using System (you could also put System.Console.WriteLine() )

  2. MyNamespace.MyClass.MyMethod() - should work with no namespace qualification (no need for a using statement)

  3. MyClass.MyMethod(); - requires the namespace declaration to remove the need to declare the namespace (MyClass cannot be seen by the compiler without the using statement to make the namespace visible)

See here for how namespacing works : https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/namespaces

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Nick Pattman