473,493 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What is the default when writing class Test

Hello!!

If you write private class Test {} you have a private class
If you write public class Test {} you have a public class
If you write protected class Test {} you have a protected class
If you write internal class Test {} you have a internal class

Now to my question
If you just write class Test {}
what access is it then on the class Test meaning what is the default access.

//Tony



May 14 '06 #1
6 1917
Hello Tony,

It's private by default

TJ> If you write private class Test {} you have a private class
TJ> If you write public class Test {} you have a public class
TJ> If you write protected class Test {} you have a protected class
TJ> If you write internal class Test {} you have a internal class
TJ> Now to my question
TJ> If you just write class Test {}
TJ> what access is it then on the class Test meaning what is the default
TJ> access.

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
May 14 '06 #2
Its PUBLIC by default. YOU CANNOT CREATE PRIVATE, PROTECTED OR PROTECTED
INTERNAL CLASS IN NAMESPACE.

"Michael Nemtsev" wrote:
Hello Tony,

It's private by default

TJ> If you write private class Test {} you have a private class
TJ> If you write public class Test {} you have a public class
TJ> If you write protected class Test {} you have a protected class
TJ> If you write internal class Test {} you have a internal class
TJ> Now to my question
TJ> If you just write class Test {}
TJ> what access is it then on the class Test meaning what is the default
TJ> access.

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

May 14 '06 #3
So many answers and all wrong...

Classes can be public or internal.
When you do not specify access modifier, classes are internal by default.

"Classes and structs are declared as internal by default unless the keyword
public is added to the class definition" [1]

[1] Access Modifiers (C# Programming Guide),
http://msdn2.microsoft.com/en-us/library/ms173121.aspx

"Altaf Al-Amin Najwani" <al**********@gmail.com> wrote in message
news:48**********************************@microsof t.com...
Its PUBLIC by default. YOU CANNOT CREATE PRIVATE, PROTECTED OR PROTECTED
INTERNAL CLASS IN NAMESPACE.

"Michael Nemtsev" wrote:
Hello Tony,

It's private by default

TJ> If you write private class Test {} you have a private class
TJ> If you write public class Test {} you have a public class
TJ> If you write protected class Test {} you have a protected class
TJ> If you write internal class Test {} you have a internal class
TJ> Now to my question
TJ> If you just write class Test {}
TJ> what access is it then on the class Test meaning what is the default
TJ> access.

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not
cease to be insipid." (c) Friedrich Nietzsche

May 14 '06 #4
Hello Lebesgue,

certainly, class can't be private in terms of C#, but it can be named private
in terms of framework.
If look at IL code you will see "private" identifier, whether you specify
"internal" or not for class it means "almost" nothing for IL.
"almost" means that if you specify "internal" it has effect on initializing
class local variables - in that case IL dosn't create it's own variables
that mapped to the V_* and uses variable that u specified (it doesn't lost
your variables names)
L> So many answers and all wrong...
L> Classes can be public or internal.
L> When you do not specify access modifier, classes are internal by
L> default.
L> "Classes and structs are declared as internal by default unless the
L> keyword public is added to the class definition" [1]
L>
L> [1] Access Modifiers (C# Programming Guide),
L> http://msdn2.microsoft.com/en-us/library/ms173121.aspx
L>
L> "Altaf Al-Amin Najwani" <al**********@gmail.com> wrote in message
L> news:48**********************************@microsof t.com...
L>
Its PUBLIC by default. YOU CANNOT CREATE PRIVATE, PROTECTED OR
PROTECTED INTERNAL CLASS IN NAMESPACE.

"Michael Nemtsev" wrote:
Hello Tony,

It's private by default

TJ> If you write private class Test {} you have a private class
TJ> If you write public class Test {} you have a public class
TJ> If you write protected class Test {} you have a protected class
TJ> If you write internal class Test {} you have a internal class
TJ> Now to my question
TJ> If you just write class Test {}
TJ> what access is it then on the class Test meaning what is the
default
TJ> access.
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do
not
cease to be insipid." (c) Friedrich Nietzsche

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
May 14 '06 #5
Hello Altaf,

Everything depends on which angle you are looking at class :)
In terms of IL if u specify internal or nothing classes are private. I meant
that case

AN> Its PUBLIC by default. YOU CANNOT CREATE PRIVATE, PROTECTED OR
AN> PROTECTED INTERNAL CLASS IN NAMESPACE.
AN>
AN> "Michael Nemtsev" wrote:
AN>
Hello Tony,

It's private by default

TJ> If you write private class Test {} you have a private class
TJ> If you write public class Test {} you have a public class
TJ> If you write protected class Test {} you have a protected class
TJ> If you write internal class Test {} you have a internal class
TJ> Now to my question
TJ> If you just write class Test {}
TJ> what access is it then on the class Test meaning what is the
default
TJ> access.
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
May 14 '06 #6
On Sun, 14 May 2006 09:08:39 GMT, "Tony Johansson"
<jo*****************@telia.com> wrote:
Hello!!

If you write private class Test {} you have a private class
If you write public class Test {} you have a public class
If you write protected class Test {} you have a protected class
If you write internal class Test {} you have a internal class

Now to my question
If you just write class Test {}
what access is it then on the class Test meaning what is the default access.


Acces modifiers in c# are by default the most restrictive.

The most restrictive modifier for elements inside a namespace is
internal. The most restrictive modifier for elements inside a class is
private.
class A //internal (Declared inside root namespace)
{
class B //private (Declared inside class a)
{
}
}

--
Marcus Andrén
May 14 '06 #7

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

Similar topics

3
1284
by: Brian van den Broek | last post by:
Hi all, I'm just starting to employ unit testing (I'm using doctest), and I am uncertain how to handle writing tests where the behaviour being tested is dependant on whether certain file paths...
4
2307
by: Duy Lam | last post by:
The compiler is complaining about "no appropriate default constructor available" when I reference a subclass. The basic setup is that i have a class Test and a subclass called TestKid. I want to...
6
2543
by: Alfonso Morra | last post by:
I have written the following code, to test the concept of storing objects in a vector. I encounter two run time errors: 1). myClass gets destructed when pushed onto the vector 2). Prog throws a...
2
1623
by: FrankStallone | last post by:
I am just getting started in XML and I made my first xml, dtd and xslt file and XML spy said they were all valid and they worked. This was the xslt doc that worked. <?xml version="1.0"...
121
9898
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
14
25231
by: DaTurk | last post by:
I am makeing a Multicast server client setup and was wondering what the difference is between Socket.Connect, and Socket.Bind. It may be a stupid question, but I was just curious. Because I...
12
2627
bartonc
by: bartonc | last post by:
For those of you who have never used the *listofargs and **dictofargs syntax, here is a look at the latter. By using **kwargs, a dictionary of any size is sent into the fuction as dict(a=1, b=2)....
89
3763
by: Skybuck Flying | last post by:
Hello, This morning I had an idea how to write Scalable Software in general. Unfortunately with Delphi 2007 it can't be done because it does not support operating overloading for classes, or...
1
1604
by: truedecembr | last post by:
Hi everyone, I am brand new to Java and not really even sure what I'm doing... I'm supposed to be writing a Timer class that is part of a stop watch application, and it seems to me that the program...
0
7119
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
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
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
7195
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...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.