473,225 Members | 1,402 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,225 software developers and data experts.

Difference between "class" and "public class"

Hi everyone,

can someone point out the difference between defining a class with the
public access modifier and just leaving it as it is (default in vs.net
"class")

I think that the default access modifier applied if one isn't defined;
so class would in fact be read as "private class" when it's compiled,
but that isn't the case.

When the code below code compiles, it will throw an error for c3, but
not for the other two classes. The fact that they're in different
namespaces also rules out that "class" is only visible within a
namespace.

I thought it might be only assembly-wide visible if defined without
the public access modifier, but, uh, I guess that's what the internal
keyword is for.

Thanks,
Matt

namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var c1 = new n1.c1();
var c2 = new n2.c2();
var c3 = new n3.c3();
}
}
}

namespace n1
{
class c1
{
}
}

namespace n2
{
class c2
{
}
}

namespace n3
{
private class c3
{
}
}
Aug 21 '08 #1
3 3321
"private class" makes no sense at the namespaec level; the default
access modifier is "internal".

So "class" (at the namespace level) is "internal class".

Marc
Aug 21 '08 #2
To clarify - for nested class the default is "private".

Marc
Aug 21 '08 #3
On Aug 21, 12:00*pm, Marc Gravell <marc.grav...@gmail.comwrote:
"private class" makes no sense at the namespaec level; the default
access modifier is "internal".

So "class" (at the namespace level) is "internal class".

Marc
Ah, Cheers!
Aug 21 '08 #4

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

Similar topics

6
by: dpr | last post by:
I have come accross a piece of C++ code with the construct: MyClass *c = new class MyClass(); Is there a difference between this and: MyClass *c = new MyClass(); ?
14
by: mshetty | last post by:
Hi, I get an error "Warning: b::a_method hides the virtual function a::a_method()." on compiling the following code.. #include <iostream.h> class a {
6
by: XiongBin | last post by:
anybody who tell me: what is the difference between "struct" and "class"? :-)
0
by: Kenneth Baltrinic | last post by:
Is the following code correct for serializing a quasi-single class, that is a class that has a descreet (though more than one, so not a true singleton) number of static instances and no dynamically...
8
by: kevin | last post by:
I have a form and in the form I have a sub that uses a class I instantiate using visual basic code: Public oCP As New Rs232 'instantiate the comm port I need to share this sub with...
1
by: timbobd | last post by:
I have encountered a situation that I don't understand. When I call a sub of Friend scope (in an object with Friend scope), I am getting an error "Public member 'subname' not found in type...
9
by: Kobe | last post by:
Is there any difference in: template <class T> vs. template <typename T> ?
0
by: AndyB | last post by:
I'm using xsd.exe to generate a typed-dataset. Then using typed dataset tables (datatables containing two columns--a name and a value) to bind to ASP.NET dropdown list controls (for the dropdown...
1
by: BobPaul | last post by:
I'm following code out of a howto book and this is really bugging me. This header file was created by VStudio 6.0 when I did a "Right Click: Add Member Function" CLine is a class I wrote (per the...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.