473,394 Members | 1,879 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,394 software developers and data experts.

Public Get/Private Set

balabaster
797 Expert 512MB
When did this get added to .NET?

Expand|Select|Wrap|Line Numbers
  1. Class Contact 
  2.  
  3.     Private _Name As String 
  4.     Private _Address As String 
  5.  
  6.     'Public Get/Private Set
  7.     Public Property Name() As String 
  8.         Get 
  9.             Return _Name 
  10.         End Get 
  11.         Private Set(ByVal value As String) 
  12.             _Name = value 
  13.         End Set 
  14.     End Property
  15.  
  16.     'Public Get/Private Set
  17.     Public Property Address() As String 
  18.         Get 
  19.             Return _Address 
  20.         End Get 
  21.         Private Set(ByVal value As String) 
  22.             _Address = value 
  23.         End Set 
  24.     End Property 
  25.  
  26. End Class
A property that's writeable from inside but readonly from outside! How did this manage to get past me before now?
Dec 4 '08 #1
3 7433
Curtis Rutland
3,256 Expert 2GB
I didn't know you could use modifiers on the get/set clauses of the properties...that's nice.

Good find.
Dec 4 '08 #2
balabaster
797 Expert 512MB
@insertAlias
I didn't either - I found some obscure code pattern on the net that I for sure thought was wrong and translated it to VB using DeveloperFusion's tool thinking it would crash because if that existed in VB I'd have found it before now - but it didn't.

So I pasted into a console app thinking that DeveloperFusion had just translated it wrong, and it works...
Dec 4 '08 #3
PRR
750 Expert 512MB
@balabaster
amazing ... tip of week...
Dec 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: quo | last post by:
two questions: 1) Does this program demonstrate the basic difference between public and private access? It appears correct to say that instances of a class cannot directly call a private...
19
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
6
by: z_learning_tester | last post by:
Quick question- What happens if you have a private class with a public static method? Can you still say the following? Lets say you are making this call from another class, say class2... int...
6
by: Sahil Malik [MVP] | last post by:
Public Private Key Pairs - How do they work? ----------------------------------------------- I was looking at a presentation recently in which it was suggested that - User 1 Encrypts a message...
10
by: darrel | last post by:
I'm still trying to sort out in my head the differences between public and shared when referring to declaring properties or variables. This is my understanding: shared - akin to a 'global'...
4
by: funVB2005fun | last post by:
I am not quite sure what I am getting into but I would like to have a loop that read from a flat file to create some public properties in a class. I am going after this to try and create more...
2
by: Sky | last post by:
Hello: I'm trying to make sense of snk files, when to use, under what conditions to regenerate new ones,...can someone take a look if these statemes make sense? And then the final questions at the...
0
by: Pilotflyhigh | last post by:
Hi, Please help. I have a class called Test public class Test { //This is my constructor public Test(string Code) { _code = Code; }
11
by: TinaJones095 | last post by:
Hello I am going to give a program that I have done, but I have to modifiy it, but I need help okay can you help ? Here the program I need help to straighten up below: the Java error is right at...
2
by: fgh.vbn.rty | last post by:
Hi, I'm not sure if i'm asking the question correctly but anyway here it is. Say I have 3 classes - class A, class B, class R. 1) A and B are the building blocks and R is like a repository...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.