Home > vb.net > Why are my classes Private by default in Visual Studio .net?

Why are my classes Private by default in Visual Studio .net?

There was an interesting question stackoverflow today.

Why are my classes Private by default in Visual Studio .net?

Here is why

By default a class without an access specifier is internal and a member defaults to private. This it keeps the visibility as restricted as possible and thereby increases encapsulation.

Making a new class public without even thinking about breaks the entire idea of encapsulation.

The class template that VS uses to create a new class can be found in this zip file (in case of CSharp):

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033\Class.zip or C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033 when using VS Orcas

Open the zip file, add the public keyword, save it and you’re done. Every time you add a class it will be public.

Check out the question here.

[Post to Twitter]   [Post to Plurk]   [Post to Digg]   [Post to ping.fm]

Hello there! If you're new here, you may want to subscribe to my RSS feeds . which is, of course, FREE :). You can also Subscribe via Email. Are you a Twitter user? then you can also follow me on Twitter. Thank you you for reading!

Related posts

Shoban vb.net

  1. No comments yet.
  1. No trackbacks yet.