Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9241703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:25:13+00:00 2026-06-18T08:25:13+00:00

According to MSDN : Public access is the normal level for a programming element

  • 0

According to MSDN:

Public access is the normal level for a programming element when you
do not need to limit access to it. Note that the access level of an
element declared within an interface, module, class, or structure
defaults to Public if you do not declare it otherwise.

So, if I declare a class method in VB.NET without specifying an access modifier, then it is public by default:

Sub DoSomething()

End Sub

This is insane! I want members to be private by default, and only those specifically marked as Public to be visible outside the class. Like in C#… How do I modify this behaviour?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:25:15+00:00Added an answer on June 18, 2026 at 8:25 am

    This is insane! I want members to be private by default

    As Fredrik has already commented, you should always provide explicit access modifiers.

    The code will be much more clear for other readers if you always
    explicitly include the access modifier.

    I assume that this is due to downwards compatibility or developers who are not familiar with access modifiers at all.

    But you are right, as in C# I would suggest to make everything as private as possible by default. You can make it more public when needed.

    Declaration Contexts and Default Access Levels (VB.NET)

    Any idea how to modify this behaviour?

    I don’t think that it’s possible to specify the default access modifier somewhere in Visual Studio. You could try to create a template-class which is suggested here (not tested):

    Visual C# 2010 Express: Specify default access modifier for new classes?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to MSDN : Parameters must be declared on public non-static fields or properties.
According MSDN, FxCop is an application that analyzes managed code assemblies (code that targets
According to MSDN (Section 11.3.6 of the C# spec ): Within an instance constructor
According to MSDN ( http://msdn.microsoft.com/en-us/library/system.windows.forms.label.autosize.aspx ), there's a note about Label 's AutoSize property:
According to this MSDN article , you should not catch general exceptions. I'm sure
According to MSDN in .Net DateTimeFormat.MonthName should contain exactly 13 elements with 12 element
According to MSDN, ArrayList.Adapter(IList) does the following: Adapter does not copy the contents of
According to MSDN documentation , public static Assembly LoadFrom(string assemblyFile) throws BadImageFormatException if assemblyFile
According to MSDN , a hash function must have the following properties: If two
According to MSDN BOL (Books Online) description on SOME | ANY (Transact-SQL) , SOME

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.