Just a silly question, but why can't you overload a writeonly property with
a readonly one? Surely the compiler can tell the difference of which one to
call at compile time, depending on if it is an assignment or a get?
I know there isn't much point to this anyway, but until Properties with
different scope for Get and Set methods are brought back (as asked by George
in a previous post about "properties with different scope", it would have
been nice to do the following:
--------------------------
Private mName As String
Public ReadOnly Property Name() As String
Get
Return mName
End Get
End Property
Protected Friend WriteOnly Property Name() As String
Set(ByVal Value As String)
mName = Value
End Set
End Property
--------------------
Saying that, it would be nicer to do this (as George and numerous others
mentioned):
-----------------------------
Private mName As String
Public Property Name() As String
Public Get
Return mName
End Get
Protected Friend Set(ByVal Value As String)
mName = Value
End Set
End Property
---------------------------- 14 3577
Hi,
At the PDC they showed the new syntax:
Private mName As String
Public Property Name() As String
Get
Return mName
End Get
Protected Friend Set(ByVal Value As String)
mName = Value
End Set
End Property
----------------------------
Note: you declare the property with the most permissible modifier, then
apply the more restrictive modifier to the Set or Get, such as Private ot
Protected etc.
"Codemonkey " <hu*********@ho tmail.com> wrote in message
news:ee******** ******@TK2MSFTN GP09.phx.gbl... Just a silly question, but why can't you overload a writeonly property
with a readonly one? Surely the compiler can tell the difference of which one
to call at compile time, depending on if it is an assignment or a get?
I know there isn't much point to this anyway, but until Properties with different scope for Get and Set methods are brought back (as asked by
George in a previous post about "properties with different scope", it would have been nice to do the following:
--------------------------
Private mName As String Public ReadOnly Property Name() As String Get Return mName End Get End Property Protected Friend WriteOnly Property Name() As String Set(ByVal Value As String) mName = Value End Set End Property
--------------------
Saying that, it would be nicer to do this (as George and numerous others mentioned):
----------------------------- Private mName As String Public Property Name() As String Public Get Return mName End Get Protected Friend Set(ByVal Value As String) mName = Value End Set End Property ----------------------------
I can see how this could be useful actually and its a shame it doesent work.
I can only assume that due to the way the compiler is designed internally
that this would have caused complications for Microsoft which were too much
to overcome. Alternatively, maybe they simply didnt think of it ?
Who knows!, perhaps you should suggest it to them
Regards - OHM#
Codemonkey wrote: Just a silly question, but why can't you overload a writeonly property with a readonly one? Surely the compiler can tell the difference of which one to call at compile time, depending on if it is an assignment or a get?
I know there isn't much point to this anyway, but until Properties with different scope for Get and Set methods are brought back (as asked by George in a previous post about "properties with different scope", it would have been nice to do the following:
--------------------------
Private mName As String Public ReadOnly Property Name() As String Get Return mName End Get End Property Protected Friend WriteOnly Property Name() As String Set(ByVal Value As String) mName = Value End Set End Property
--------------------
Saying that, it would be nicer to do this (as George and numerous others mentioned):
----------------------------- Private mName As String Public Property Name() As String Public Get Return mName End Get Protected Friend Set(ByVal Value As String) mName = Value End Set End Property ----------------------------
Regards - OHM# On**********@BT Internet.com
By new you mean Whidbey ?
regards - OHM#
Bill McCarthy wrote: Hi,
At the PDC they showed the new syntax:
Private mName As String Public Property Name() As String Get Return mName End Get Protected Friend Set(ByVal Value As String) mName = Value End Set End Property ----------------------------
Note: you declare the property with the most permissible modifier, then apply the more restrictive modifier to the Set or Get, such as Private ot Protected etc.
"Codemonkey " <hu*********@ho tmail.com> wrote in message news:ee******** ******@TK2MSFTN GP09.phx.gbl... Just a silly question, but why can't you overload a writeonly property with a readonly one? Surely the compiler can tell the difference of which one to call at compile time, depending on if it is an assignment or a get?
I know there isn't much point to this anyway, but until Properties with different scope for Get and Set methods are brought back (as asked by George in a previous post about "properties with different scope", it would have been nice to do the following:
--------------------------
Private mName As String Public ReadOnly Property Name() As String Get Return mName End Get End Property Protected Friend WriteOnly Property Name() As String Set(ByVal Value As String) mName = Value End Set End Property
--------------------
Saying that, it would be nicer to do this (as George and numerous others mentioned):
----------------------------- Private mName As String Public Property Name() As String Public Get Return mName End Get Protected Friend Set(ByVal Value As String) mName = Value End Set End Property ----------------------------
Regards - OHM# On**********@BT Internet.com
Hi Codemonkey,
I sometimes get the idea that people want to use C with VB.
I am thinking than always: "when those things are so important, why don't
those people switch to C?
What I find crazy is that I cannot simple write
Set
mName = Value
End Set
And when I want to use another value
Set (AnotherValue)
mName = AnotherValue
End Set
I write this, to give a contra opinion about this in this newsgroup, not
that I find it really important.
Cor
Even better. Cheers Bill.
"Bill McCarthy" <bi******@i.pri mus.com.au> wrote in message
news:On******** ******@TK2MSFTN GP11.phx.gbl... Hi,
At the PDC they showed the new syntax:
Private mName As String Public Property Name() As String Get Return mName End Get Protected Friend Set(ByVal Value As String) mName = Value End Set End Property ----------------------------
Note: you declare the property with the most permissible modifier, then apply the more restrictive modifier to the Set or Get, such as Private ot Protected etc.
"Codemonkey " <hu*********@ho tmail.com> wrote in message news:ee******** ******@TK2MSFTN GP09.phx.gbl... Just a silly question, but why can't you overload a writeonly property with a readonly one? Surely the compiler can tell the difference of which one to call at compile time, depending on if it is an assignment or a get?
I know there isn't much point to this anyway, but until Properties with different scope for Get and Set methods are brought back (as asked by George in a previous post about "properties with different scope", it would
have been nice to do the following:
--------------------------
Private mName As String Public ReadOnly Property Name() As String Get Return mName End Get End Property Protected Friend WriteOnly Property Name() As String Set(ByVal Value As String) mName = Value End Set End Property
--------------------
Saying that, it would be nicer to do this (as George and numerous others mentioned):
----------------------------- Private mName As String Public Property Name() As String Public Get Return mName End Get Protected Friend Set(ByVal Value As String) mName = Value End Set End Property ----------------------------
Who knows!, perhaps you should suggest it to them
No point. Properties with different scope are gonna be in the next version
as Bill mentioned anyway. Aside from Properties, I can't really see there
being any need for overloading Fields with different scope modifiers.
"One Handed Man [ OHM# ]" <On**********@B TInternet.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. I can see how this could be useful actually and its a shame it doesent
work. I can only assume that due to the way the compiler is designed internally that this would have caused complications for Microsoft which were too
much to overcome. Alternatively, maybe they simply didnt think of it ?
Who knows!, perhaps you should suggest it to them
Regards - OHM#
Codemonkey wrote: Just a silly question, but why can't you overload a writeonly property with a readonly one? Surely the compiler can tell the difference of which one to call at compile time, depending on if it is an assignment or a get?
I know there isn't much point to this anyway, but until Properties with different scope for Get and Set methods are brought back (as asked by George in a previous post about "properties with different scope", it would have been nice to do the following:
--------------------------
Private mName As String Public ReadOnly Property Name() As String Get Return mName End Get End Property Protected Friend WriteOnly Property Name() As String Set(ByVal Value As String) mName = Value End Set End Property
--------------------
Saying that, it would be nicer to do this (as George and numerous others mentioned):
----------------------------- Private mName As String Public Property Name() As String Public Get Return mName End Get Protected Friend Set(ByVal Value As String) mName = Value End Set End Property ----------------------------
Regards - OHM# On**********@BT Internet.com
> when those things are so important, why don't those people switch to C?
I have switched to C# in the past for some things, but what's wrong with
trying to improve VB?
What I find crazy is that I cannot simple write
Set mName = Value End Set
That doesn't really bother me as the IDE puts in the syntax automatically
when I press return after typing in the first line of the Property. Jeeze,
I'm lazy ;)
Trev.
"Cor" <no*@non.com> wrote in message
news:eA******** ******@tk2msftn gp13.phx.gbl... Hi Codemonkey,
I sometimes get the idea that people want to use C with VB. I am thinking than always: "when those things are so important, why don't those people switch to C?
What I find crazy is that I cannot simple write
Set mName = Value End Set
And when I want to use another value
Set (AnotherValue) mName = AnotherValue End Set
I write this, to give a contra opinion about this in this newsgroup, not that I find it really important.
Cor
"Codemonkey " <hu*********@ho tmail.com> schrieb Just a silly question, but why can't you overload a writeonly property with a readonly one? Surely the compiler can tell the difference of which one to call at compile time, depending on if it is an assignment or a get?
I know there isn't much point to this anyway, but until Properties with different scope for Get and Set methods are brought back (as asked by George in a previous post about "properties with different scope", it would have been nice to do the following:
It is a contradiction that a property is readonly *and* writeonly. If you
can only read, you can not write or even write only.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
I understand this, I was making the point about using this to get around the
problem of having different scope for proeprty set and property let (Public
Readlonly Get, Protected Writeonly Set etc.)
It's supposedly gonna be included in the next version, so no matter.
Trev.
"Armin Zingler" <az*******@free net.de> wrote in message
news:uW******** ******@tk2msftn gp13.phx.gbl... "Codemonkey " <hu*********@ho tmail.com> schrieb Just a silly question, but why can't you overload a writeonly property with a readonly one? Surely the compiler can tell the difference of which one to call at compile time, depending on if it is an assignment or a get?
I know there isn't much point to this anyway, but until Properties with different scope for Get and Set methods are brought back (as asked by George in a previous post about "properties with different scope", it would have been nice to do the following:
It is a contradiction that a property is readonly *and* writeonly. If you can only read, you can not write or even write only.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon |
last post by:
Hi all,
What is the equivalent code of the following in C#?
**********************************************************
Public ReadOnly Property EditURL(ByVal strKeyName As
String, ByVal strKeyValue As String) As String
Get
|
by: Marina |
last post by:
Hi,
I have a class that inherits from CollectionBase, and I'm trying to override
its Count property. As per the documentation, this property is overridable -
so I should be able to do this. So this is my code:
Public Overrides ReadOnly Property Count() As Integer
Get
End Get
End Property
|
by: besaar |
last post by:
i got the current project that got the serial no.of a hard disk for
software protection but i got an error,if u solve it send me,thanx
alllllll.
1.file1
Option Strict On
Option Explicit On
Imports System.Runtime.InteropServices
Public Class DriveInfo
|
by: Schorschi |
last post by:
Can't seemd to get ReadFile API to work! Returns invalid handle
error?
===========================================================================
Ok, the visual basic gurus, help!
The following is a diskette class (vb .net) that works find, in that I
can validate a diskette is mounted, dismount it, lock it, unlock it,
get diskette geometry, etc., all with a valid handle from CreateFile
API! I can even position the file pointer,...
|
by: Able |
last post by:
Dear friends
In a class I have this property:
Private mstr_FirstName As String
Public Property FirstName() As String
Get
| |
by: Nick Hall |
last post by:
I'm getting what I think is a bug in the way the VB compiler determines the
correct overloaded method to call. I have written a class to wrap
System.Configuaration.ConfigurationSettings with some type-safe methods -
for instance two methods are : -
Public Overloads Shared Function GetInt32(ByVal key As String, ByVal
defaultValue As Integer) As Integer
....
End Function
|
by: Philip Wagenaar |
last post by:
I created a Mustinherit class with two must override readonly properties:
Public MustInherit Class RequestPart
Public MustOverride ReadOnly Property Description() As Boolean
Public MustOverride ReadOnly Property Mandatory() As String
End Class
I the derived class I cannot override the property Mandatory because the
return types differ:
|
by: Rich |
last post by:
Yes, I need to store some values in an array type collection object that can
hold 3 or more parameters per index. I have looked at the collection object,
hashtable object and would prefer not to hassel with a multi-dimensional
array. Is there such an object in VB.Net?
Dim obj As someCollectionObj
obj.Add("parmA1", "parmA2", "parmA3")
obj.Add("parmB1", "parmB2", "parmB3")
....
|
by: Andrus |
last post by:
I'm implementing entity object which should populate its properties from
database when property is first referenced.
In RDL reports I use object properties like
MyObject.MyProperty
MyObject is instance of MyEntity class. There is no MyProperty property in
MyObject at design time.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |