private struct

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

I have a .cs file that contains a public class and a public struct in a
single namespace. I decided I wanted the struct to only be accessible to
the class, and not to the rest of my project. I changed the public struct
to a private struct, but it gave me the following error ... why? What are
my options? Thanks in advance! - Mark

"Namespace elements cannot be explicitly declared as private, protected, or
protected internal."
 
If you want it internal to the class only, then nest it inside the class and
make it private (e.g. nested class/struct). If you want it internal to your
namespace, put it in your namespace and make it internal.
 
Sorry to disagree, but a class cannot be internal to a namespace, only too
an assembly.

Regards,

Jasper Kent.
 
Sorry Jasper, that is what I meant. Put it in the namespace and make it
internal - which will make it internal to the assembly. I assumed his
namespace was the only one in the assembly as he noted a single namespace.
 
Back
Top