C# Error CS1671 – A namespace declaration cannot have modifiers or attributes

C# Error

CS1671 – A namespace declaration cannot have modifiers or attributes

Reason for the Error & Solution

A namespace declaration cannot have modifiers or attributes

Modifiers are not meaningful when applied to a namespace, so they are not allowed.

The following sample generates CS1671:

// CS1671.cs  
public namespace NS // CS1671  
{  
  
}