Protected access modifier in Struct

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Hi,

Please do tell me why i cant have a protected access modifier in a struct?
i get this error

namespace StructExample
{
class Tester
{
static void Main(string[] args)
{
//instance of struct
}
}

internal struct Location
{
protected Location(int xCoordinate, int yCoordinate, int StatusValue)
{
//initialization
}
}
}

"StructExample.Location.Location(int, int, int)' : new protected member
declared in struct" -- Error Message


Thanks,
Stephen
 
Structure members can't be protected because you cannot inherit from a
struct...doesn't make sense why you'd do it, so they don't let you.

Karl
 
Thanks Karl

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:OQ%[email protected]...
Structure members can't be protected because you cannot inherit from a
struct...doesn't make sense why you'd do it, so they don't let you.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Stephen said:
Hi,

Please do tell me why i cant have a protected access modifier in a struct?
i get this error

namespace StructExample
{
class Tester
{
static void Main(string[] args)
{
//instance of struct
}
}

internal struct Location
{
protected Location(int xCoordinate, int yCoordinate, int StatusValue)
{
//initialization
}
}
}

"StructExample.Location.Location(int, int, int)' : new protected member
declared in struct" -- Error Message


Thanks,
Stephen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top