473,397 Members | 2,099 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,397 software developers and data experts.

VB default class access modifier

I have read conflicting information on the access scope
of VB.Net class declarations when no access modifier is
specified. MSDN library documentation states "Classes
that do not specify an access modifier are declared as
Friend by default" However, another source, VB.Net Class
Design Handbook by Wrox Press states that no a "no class
access modifier results in an implicit scope of public to
all assemblies". In fact, if I create a class with no
access modifier, compile the example, then view the MSIL
code in the MSIL Disassemble (using ILdasm.exe), I see
that this class is qualified with the MSIL keyword
public; i.e., it has the same scope as a class I declared
as Public. ????? Please straighten this out for me.
Jul 21 '05 #1
2 3509
Which version of the VB compiler are you using? I'm getting private by
default. Also, where is this documentation?

Thanks,
-mike
MVP

"Dan Disney" <dj*@ridgenet.net> wrote in message
news:75****************************@phx.gbl...
I have read conflicting information on the access scope
of VB.Net class declarations when no access modifier is
specified. MSDN library documentation states "Classes
that do not specify an access modifier are declared as
Friend by default" However, another source, VB.Net Class
Design Handbook by Wrox Press states that no a "no class
access modifier results in an implicit scope of public to
all assemblies". In fact, if I create a class with no
access modifier, compile the example, then view the MSIL
code in the MSIL Disassemble (using ILdasm.exe), I see
that this class is qualified with the MSIL keyword
public; i.e., it has the same scope as a class I declared
as Public. ????? Please straighten this out for me.

Jul 21 '05 #2
Dan,

For top-level classes, the default is Friend (which at this level is
effectively the same as Private). For nested classes, the default is
Public.

So the following code

Class Foo
Class Bar
End Class
End Class

compiles to

..class private Foo
{
.class nested public Bar
{
}
}

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Jul 21 '05 #3

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

Similar topics

4
by: Gerben van Loon | last post by:
Hello, I'm quite new to Csharp and like to know how I can call a function from an upper class. Following example might explain my problem a bit better: public class MyClass { public void...
1
by: Jacob N. Rohde | last post by:
Hi guys, I was under the assumption that the default type access modifier for classes/structs is internal. But the MCAD Study Guide (from MS even) says public?!?! (The Dr. GUI .NET tutorial from...
1
by: Mark Kamoski | last post by:
Hi-- Please help. What is the default access modifier value for a Sub or a Function when one has not explicitly been set. In MSDN, in "Access Types", it states... "If no access modifier...
5
by: Harold Hsu | last post by:
Hi all, What's the default access type of a property declared in an interface? The one I'm looking at is IBindingList: Public Interface IBindingList .... ReadOnly Property AllowEdit As...
19
by: hamil | last post by:
I have a form with one button, Button1, and a Textbox, Textbox1 I have a class, class1 as follows. Public Class Class1 Public DeForm As Object Sub doit() DeForm.Textbox1.text = "It works"...
2
by: Dan Disney | last post by:
I have read conflicting information on the access scope of VB.Net class declarations when no access modifier is specified. MSDN library documentation states "Classes that do not specify an access...
11
by: prefersgolfing | last post by:
I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
6
by: Tony Johansson | last post by:
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...
8
by: puzzlecracker | last post by:
/*1 not specified*/class { /*2 not specified*/ void Foo(){} } Will they, like in c++, default to private? Thanks
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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,...

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.