Have The Get Part Of A Property Available As Public But Keep The Set As Private?
Sep 22, 2009
is there a way to have the Get part of a property available as public, but keep the set as private?Otherwise I am thinking I need two properties or a property and a method, just figured this would be cleaner.
I searched on the forum / Internet for the solution how a PropetryInfo object (of a Public property) can reveal if it has a Private Protected Setter ... it was all in vain .... all help I found was about how to "Set" value of a public property having a Private Setter.I would like to know if I have a PropertyInfo object of a public property, how would I know if its Setter is Non Public?
I tried, in a exception handling block, where I did a GetValue of the PropertyInfo object and then called SetValue by setting the same value back... but to my surprise it worked well and didn error out.
explain me the difference between them? I'm new to visual basic, and I need to know the very basic things in Visual Basic allowing me to become a professional User
I'm new to C#.Till this moment I used to make every global variable - public static.All my methods are public static so I can access them from other classes. I read on SO that the less public static methods I have,the better.So I rewrote my applications by putting all the code in one class - the form class.Now all my methods are private and there's no static method.
My question: What should I do,keeping everything in the form class is dump in my opinion. When should I use public,when private and when static private/public? I get the public methods as a 'cons' ,because they can be decompiled,but I doubt that.My public methods can be decompiled too.What is so 'private' in a private method? EDIT: I'm not asking how to prevent my program to be decompiled,I'm asking whether I should use static,private and public.And also : Is there are problem in putting all the code in the form class so I dont have to use public methods?
I am a little new to .NET Developing, and have learned a great deal recently, but I'm stuck with something. I come from an ASP Background, I'm trying to subtract 2 variables, but they don't seem to 'see' one another.
Private Sub ActivateMe(ByVal active As Boolean) Implements IGraphicControl .ActivateMe compiles.How is possible in VB.NET? A private method can be an interface implementation. VB.NET... a lot of compliments to this language and IDE..
I have a public variable which seems to be going out of scope. I am confused as it has been dimensioned as a public variable: Public xlCell as As Microsoft.Office.Interop.Excel.Range
I originally had all my code in the same module in the same project and it was wrapped within a For/Next Loop (Example 1). I decided to clean up my code and make it more modular (Example 2). All the code is still in the same module in the same project.
Upon doing so, my public variable is not recognized in any of the private subs that I have created. I keep getting the following error: Message="Object reference not set to an instance of an object." When I test the variable using ?IsNothing(xlCell) in the Main Sub I get False in the main sub. this tells me te variable is recognized. However as soon as the Call SelectCaseSub() is triggered, I get a True value for ?IsNothing(xlCell). Why is this? Shouldn't this variable be in scope regardless?
I have a situation where I need to make some data available for reading by anyone from a specific device, where the data is pre-loaded on the device, but I cannot allow anyone to create their own device and populate it with their own data in the same format.I know this sounds a little crazy, but there is a good reason!I was planning to use Public Key cryptography, encrypting the data with a public key, but then publishing the private key to anyone who wants to read the data.
I'm relatively new to .NET and am wondering how people handle naming their private variables and the public properties that access them. Like if you want to be able to just read it, but not write to it.
[Code]...
So far I've taken to putting a 'l' (for local) in front of the all the private variables so as to be able to use the full name for the property. Is there a better way around this, or do you just always have to have different names for private variable/public properties? If so, what sort of conventions do people use?
Its not a huge deal, its just a minor annoyance and I was wondering if I was missing something.
what websites, books or courses you guys suggest to use so I learn the fundamentals of programming. What is a class, method, namespace, private vs public. That leads me into .Net programming. A lot of intro to programming use java or C++ as the platform but I want to find one with VB.net or maybe C# if.
Public Class Form1 Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub btnChoose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChoose.Click[code]....
I need to know what I can do to skip from the radio button 1 part to the private sub question 2..
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim example1 As New ExampleClass[code]......
I have a bunch of private variables I've typed out and I want to put all of my corresponding Public ReadOnly Properties in a bunch below them.Is there some way of copying ten lines of
Private _myVar As String
and pasting in ten sets of
Public Readonly Property MyVar As String Get Return _myVar[code]....
I'm currently copying the whole bunch of variable declarations, Find+Replacing Private _ into Public ReadOnly Property then going line-by-line expanding the definitions and writing return statements.how to avoid all this nonsense in the future, as I'm developing on a virtual terminal server, and the input lag on my little copy/paste/type operations on the code is driving me up the wall.
give me a good resource that explains the difference between a Private, Public, Shared Functions/Sub/Variables? I normally use Public for Subs/Functions inside of Modules I call from other parts of the program. But I'd like to get more of an understanding of how and when to use them. I want as little as impact to a system that is running my programs as possible, so i guess the key here is I'm trying to just get more proficient in my coding.
I'm working in .net environment (all versions) and using vb.net. I want to generate RSA public and private keys based on a passphrase. RSA algorithm only limited by using a class provided by the .net ie System.Security.Cryptography.RSACryptoServiceProvider Class. I know how to generate random RSA public/private keys and perform encryption/decryption.But that .net class don't let us creating RSA public/private keys based on a passphrase.
I have these list of RS-232 strings declared in my public class Public Class TouchInterface Dim WatchTVbtnCmd As String = "rs232command1" Dim VolUpbtnCmd As String = "rs232command2" Dim VolDownbtnCmd As String = "rs232command3" Dim SystemOffbtnCmd As String = "rs232command4" Dim RadiobtnCmd As String = "rs232command5" Dim MusicbtnCmd As String = "rs232command6"
I then have this private sub. For the sake of this thread, what I would like to do is get the name of the label that was clicked which in the code below is already done, convert it to string (not sure if this needs to be done), this is also done in the code below. Next I want to compare the labelnamestring to all the variables in the public class to find out which one it is equal to and then disply that variable which should be my rs232 string in the message box. I have also added "Cmd" to the variable names above so I also need to work out how to add the text "Cmd" to the string to properly compare.
Private Sub Musicbtn_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WatchTvbtn.Click, VolUpbtn.Click, VolDownbtn.Click, SystemOffbtn.Click, Radiobtn.Click, Musicbtn.Click, GardenVolUpbtn.Click, GardenVolDownbtn.Click, GardenRadiobtn.Click, GardenOffbtn.Click, GardenMusicbtn.Click, GardenMediaCenterbtn.Click Dim labelname As Label = DirectCast(sender, Label) [Code] .....
I have been told before that it is possible to create sections of code which can be collapsed and expanded like a normal Public or Private Sub, but containing multiple Public Subs So say I have code for a variety of textboxes I wanted to be able to collapse, how would I do this?
I am trying to use fluent nhibernate in a MVC project. It seems the entities should have properties that are virtual and the set should be private for IDs. I use vb language. So tried using overrideable. It gives an error...
Public Overridable Property DesignId() As Integer Get End Get Private Set(ByVal value As Integer) End Set End Property
It says property cannot be overrideable because it has a private accessor.
I'd like to have a Private or Protected "Setter" for a property that also happens to be an abstract (MustOverride). I'm porting some code from C# to VB and in C# this is pretty straight forward. In VB not so much (for me anyway).
Some code...
In C#... public abstract class BaseClassWithAnAbstractProperty { public abstract int AnAbstractIntegerProperty { get; protected set; } }
[Code]....
The issue seems to be the inability to flesh-out the Get/Set specifics in the declaration.
I am programmer from some time only, I have certain doubts in fundamentals, could you please clarify on the following:Case 1:
[Code]...
Does case 1 and case 2 yield same result, I mean is a private value necessarily in there?, can we use property itself to use its own value in its Set and get statements?
Is it possible to set a variable in my custom class for Private Read/Write access and Public Readonly access without creating Properties with Get and Set? In other words, from within my class I want full access and from my form I only want read access. Right now I declare my variable as either Private or Public to control Public read/write access. I tried googling my question a bit but I'm not sure what the correct terms even ar
It works, when I make getBar methods public, but I don't want to expose these unneccessarily. Why I can't call private shared methods from a public one in the same class is over my head. I'm using .net framework 4.0 in a web application.