473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Protected access modifier in Struct

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
Apr 6 '06 #1
2 1530
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" <st********@hotmail.com> wrote in message
news:Oa**************@TK2MSFTNGP05.phx.gbl...
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

Apr 6 '06 #2
Thanks Karl

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:OQ****************@TK2MSFTNGP04.phx.gbl...
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" <st********@hotmail.com> wrote in message
news:Oa**************@TK2MSFTNGP05.phx.gbl...
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


Apr 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: AIK | last post by:
I have the following two classes: package birdpack; public class Bird { Bird() {} protected int nFeathers;
2
by: Hin | last post by:
from MSDN, decription for protected internal is "Access is limited to the current project OR types derived from the containing class" Is there any way i can have the access limited to the...
3
by: Chua Wen Ching | last post by:
Hi there, I had seen examples for classes, but i had no idea how to implement the same thing in struct. I am quite mix up! Which one is correct? Scenario: WForm.cs - the one that calls...
3
by: Nathan Wiegman | last post by:
Hi, Why must derived classes access protected base members through an instance of a derived class? The following code would work in C++, why doesn't it in C#? public class A { protected...
2
by: Kolozs, Áron | last post by:
Hi everybody, The C# compiler reports a Compiler Error CS0052 in the following situation: I declared a type marked as "internal": namespace MyNamespace { internal class MyInteralClass
5
by: | last post by:
hello there, what is the difference between Shared and Protected Shared? where can I read more about theses kind of variables (or whatever they are....sorry, don't know the word in eng.) ...
16
by: Fir5tSight | last post by:
Hi All, I have a small C#.NET program that is as follows: using System; class A { protected int x = 123; }
13
by: Tom Baxter | last post by:
Hi everyone, Has anyone looked at section 18.1.1 of the C# spec? It indicates 'new' and 'protected' are valid modifiers on struct declarations. First, how can 'protected' be valid on a struct,...
8
by: Mayur H Chauhan | last post by:
All, For my knowledge, if I declare Class as follow, then it thows compilation error. Protected Class Book End Class Even same for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.