Question Supress Private Variables in .NET Classes

Element6

Well-known member
Joined
Feb 16, 2010
Messages
85
Programming Experience
5-10
Does anyone know how to supress the private variables from showing in the .NET Namespace?

I have a Class that looks similar to this.

VB.NET:
[B]Public Class SomeClassA

   Private propA as string

   Public Property SOMEPROP() as String
   Get
      return propA
   End Get
   Set(value as string)
       propA = value
   End Set
   End Property

End Class[/B]


When I use the class in a programing environment the "propA" Value appears in the namespace when I hit SomeClassA"." .

Does anyone know how to supress this or is there a different technique to use that hides the reference that I don't know about?
 
I noticed that when I first moved to VS 2008. Back in VS 2003 and 2005 it would only list the members you have access to, whereas VS 2008 shows everything. I haven't tried assigning something to the one I know is a private var outside of that class, it should give a compile error.
 
When you make an instance of that class you will not see it in Intellisense.
VB.NET:
Dim s As New SomeClassA
s.propA '<- will never show up where 
s.SOMEPROP 'will, and you would set the propA by setting this
 
Ok good, because I was getting annoyed with all my private declares poping up in the intellisense, and would hate to see my Framework reflect all the hardwork I put in for security by showing it when I distribute and nullify what I have done.

Is there no option to "turn off" this feature in Development Environment maybe?

If I have a complex derived class that has, lets say 10 properties Public and 10 Private for swap ajustment or persistance accumulative from 2 or 3 bases classes; it lists all 20 and that is very cumbersome when routeing through and especially when I am trying to remember which Classes the origional Properties/Methods/Events are located in; which is my fault really, I tend not to use the PARTIAL Classes method of solving that problem and like to view the universe from a logical view not a Business view (which I know would solve my organization problems).

I was hoping Microsoft would have been a little smarter with this and added a dataset style intellisense which shows the property infromation, such as PROPERTY | DATATYPE | LOCATION (BASE CLASS) or perhaps a way of Turning on and off descriptors and information as needed to "personalize" the Development Environment.

I do like intellisense a lot though very smart and it is very useful.

Thanks again appreciate the help.
 
Reflection

Mate,

All private variables, members etc can be read using reflection so turning them off in intellisense only gives a false sense of security. Its surely better knowing that they are not private and coding securely.
 
So if I wanted to peer into the Microsoft Framework I can just use Reflection to do Gettype information?

Well, that seems to defeat the whole purpose of Private.

Senior Developers - Would you suggest that instead of using private declaration I just make a persistant array class and uses some sort of property Indexing to be able to view the information? It's encumbered; but I don't want to lose security and I need to add some levels to the model; problem is more code = slower output and hackers exists so I need to rethink this. Maybe .NET isn't the right framework to be using.

I think .NET needs to add new technique styles so that people can get around these issues easily.
 
Back
Top