I would like to refer to properties in code without having to resort to
using a string for the name. AddessOf gives me this ability for methods, but
I can't find a single way to point that at the Get or Set methods of
properties directly.
Why don't I want to use a string? Well, I want to know at design time that
my property references aren't broken, much the same way I can have this when
using regular delegates.
Is this possible?
Paul 6 1410
Hi,
You should take a look at generics in vb 2005. http://msdn2.microsoft.com/en-us/library/ms172192.aspx
Ken
-----------------------
"PJ6" <no***@nowhere. net> wrote in message
news:Om******** ******@TK2MSFTN GP05.phx.gbl... I would like to refer to properties in code without having to resort to using a string for the name. AddessOf gives me this ability for methods, but I can't find a single way to point that at the Get or Set methods of properties directly.
Why don't I want to use a string? Well, I want to know at design time that my property references aren't broken, much the same way I can have this when using regular delegates.
Is this possible?
Paul
Unfortunately that has nothing to do with getting at the Set and Get methods
in a Property without first having to get the ProperyInfo with a string
representing its name...
Or am I not understanding how to apply that information to my question?
Thanks,
Paul
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:u3******** ******@TK2MSFTN GP05.phx.gbl... Hi,
You should take a look at generics in vb 2005.
http://msdn2.microsoft.com/en-us/library/ms172192.aspx
Ken ----------------------- "PJ6" <no***@nowhere. net> wrote in message news:Om******** ******@TK2MSFTN GP05.phx.gbl...I would like to refer to properties in code without having to resort to using a string for the name. AddessOf gives me this ability for methods, but I can't find a single way to point that at the Get or Set methods of properties directly.
Why don't I want to use a string? Well, I want to know at design time that my property references aren't broken, much the same way I can have this when using regular delegates.
Is this possible?
Paul
Paul,
Are you sure that VBNet is the right program language for you.
Using addresspointers to references is maybe for some a nice way of
programming, it is in my idea a litle bit out of sense to base your complete
system on it. Like an API it is a nice way to escape as nothing seems to be
more possible, to use in general is in my idea a little bit crazy.
What you see is that where it is needed, that need is often eliminiated in
the next version.
Is C++ not a better language for you?
Cor
"PJ6" <no***@nowhere. net> schreef in bericht
news:Oa******** ******@TK2MSFTN GP02.phx.gbl... Unfortunately that has nothing to do with getting at the Set and Get methods in a Property without first having to get the ProperyInfo with a string representing its name...
Or am I not understanding how to apply that information to my question?
Thanks, Paul
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message news:u3******** ******@TK2MSFTN GP05.phx.gbl... Hi,
You should take a look at generics in vb 2005.
http://msdn2.microsoft.com/en-us/library/ms172192.aspx
Ken ----------------------- "PJ6" <no***@nowhere. net> wrote in message news:Om******** ******@TK2MSFTN GP05.phx.gbl...I would like to refer to properties in code without having to resort to using a string for the name. AddessOf gives me this ability for methods, but I can't find a single way to point that at the Get or Set methods of properties directly.
Why don't I want to use a string? Well, I want to know at design time that my property references aren't broken, much the same way I can have this when using regular delegates.
Is this possible?
Paul
Cor,
The reason for my desire to get pointers from property methods without using
strings is simple, and that is the holding to the principle of code
normalization. In my grid, when I want to point a column to a property in
code, I don't want to have to write out the property name with a string such
as "SomeProper ty". This is wrong because there is no design-time
verification that the string is correct, and if I manage to change the
property name later, or I've misspelled it, I will have no idea that
something is broken until something fails at runtime. Put more simply, I
want design-time validation of property references. Why do you think that's
crazy?
What surprises me is that I apparently cannot generate a pointer to the
property Set and Get methods the same way I can for normal methods. For
normal methods, this isn't an issue at all, I don't need to spell the method
name out in a string to get at it for use as a delegate.
Yes. Apparently this is currently a deficiency in the Framework since no one
has chimed in to say otherwise. But I'm not going to throw my hands up in
the air and compromise my design or move to C just because I run into a
limitation like this; I will look for a way around it.
Paul
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. .. Paul,
Are you sure that VBNet is the right program language for you.
Using addresspointers to references is maybe for some a nice way of programming, it is in my idea a litle bit out of sense to base your complete system on it. Like an API it is a nice way to escape as nothing seems to be more possible, to use in general is in my idea a little bit crazy.
What you see is that where it is needed, that need is often eliminiated in the next version.
Is C++ not a better language for you?
Cor
"PJ6" <no***@nowhere. net> schreef in bericht news:Oa******** ******@TK2MSFTN GP02.phx.gbl... Unfortunately that has nothing to do with getting at the Set and Get methods in a Property without first having to get the ProperyInfo with a string representing its name...
Or am I not understanding how to apply that information to my question?
Thanks, Paul
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message news:u3******** ******@TK2MSFTN GP05.phx.gbl... Hi,
You should take a look at generics in vb 2005.
http://msdn2.microsoft.com/en-us/library/ms172192.aspx
Ken ----------------------- "PJ6" <no***@nowhere. net> wrote in message news:Om******** ******@TK2MSFTN GP05.phx.gbl... I would like to refer to properties in code without having to resort to using a string for the name. AddessOf gives me this ability for methods, but I can't find a single way to point that at the Get or Set methods of propertie s directly.
Why don't I want to use a string? Well, I want to know at design time that my property references aren't broken, much the same way I can have this when using regular delegates.
Is this possible?
Paul
Paul,
I am not sure if this is the answer, however you can inherit almost every
class. In that way you can make it strongly typed.
Have a look at the generated strongly typed datasource in 2005 or the
generated strongly typed dataset in previous versions as it is generated.
Cor
"PJ6" <no***@nowhere. net> schreef in bericht
news:ep******** ******@TK2MSFTN GP04.phx.gbl... Cor,
The reason for my desire to get pointers from property methods without using strings is simple, and that is the holding to the principle of code normalization. In my grid, when I want to point a column to a property in code, I don't want to have to write out the property name with a string such as "SomeProper ty". This is wrong because there is no design-time verification that the string is correct, and if I manage to change the property name later, or I've misspelled it, I will have no idea that something is broken until something fails at runtime. Put more simply, I want design-time validation of property references. Why do you think that's crazy?
What surprises me is that I apparently cannot generate a pointer to the property Set and Get methods the same way I can for normal methods. For normal methods, this isn't an issue at all, I don't need to spell the method name out in a string to get at it for use as a delegate.
Yes. Apparently this is currently a deficiency in the Framework since no one has chimed in to say otherwise. But I'm not going to throw my hands up in the air and compromise my design or move to C just because I run into a limitation like this; I will look for a way around it.
Paul
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message news:%2******** ********@TK2MSF TNGP04.phx.gbl. .. Paul,
Are you sure that VBNet is the right program language for you.
Using addresspointers to references is maybe for some a nice way of programming, it is in my idea a litle bit out of sense to base your complete system on it. Like an API it is a nice way to escape as nothing seems to be more possible, to use in general is in my idea a little bit crazy.
What you see is that where it is needed, that need is often eliminiated in the next version.
Is C++ not a better language for you?
Cor
"PJ6" <no***@nowhere. net> schreef in bericht news:Oa******** ******@TK2MSFTN GP02.phx.gbl... Unfortunately that has nothing to do with getting at the Set and Get methods in a Property without first having to get the ProperyInfo with a string representing its name...
Or am I not understanding how to apply that information to my question?
Thanks, Paul
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message news:u3******** ******@TK2MSFTN GP05.phx.gbl... Hi,
You should take a look at generics in vb 2005.
http://msdn2.microsoft.com/en-us/library/ms172192.aspx
Ken ----------------------- "PJ6" <no***@nowhere. net> wrote in message news:Om******** ******@TK2MSFTN GP05.phx.gbl... >I would like to refer to properties in code without having to resort to >using a string for the name. AddessOf gives me this ability for >methods, but I can't find a single way to point that at the Get or Set >methods of properties directly. > > Why don't I want to use a string? Well, I want to know at design time > that my property references aren't broken, much the same way I can > have this when using regular delegates. > > Is this possible? > > Paul >
PJ6,
Unfortunately AddressOf only works on Subs & Functions not properties.
As Cor suggests, I too wonder what specifically you are doing that requires
the use of the underlying delegates.
If your design truely needs the delegates & using a string to retrieve them
is undesirable. Have you considered a design that uses a Get function & a
Set sub instead?
In other words, instead of:
Public Property Name As String
...
Use:
Public Function GetName() As String
...
Public Sub SetName(value As String)
...
Alternatively I would consider a design that each "property" was actually an
object instead, then instead of relying on delegates to the "properties "
method, I would use simply pass the "property" object instead. I would
consider using Generics to define the "property" object...
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"PJ6" <no***@nowhere. net> wrote in message
news:Om******** ******@TK2MSFTN GP05.phx.gbl...
|I would like to refer to properties in code without having to resort to
| using a string for the name. AddessOf gives me this ability for methods,
but
| I can't find a single way to point that at the Get or Set methods of
| properties directly.
|
| Why don't I want to use a string? Well, I want to know at design time that
| my property references aren't broken, much the same way I can have this
when
| using regular delegates.
|
| Is this possible?
|
| Paul
|
| This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: kode |
last post by:
im having problems trying to understand the delegates in
c#, does anybody know some link where i can find a good
and simple explanation?
thanks
|
by: Natalia DeBow |
last post by:
Hi,
I am working on a Windows-based client-server application. I am involved in
the development of the remote client modules. I am using asynchronous
delegates to obtain information from remote server and display this info on
the UI.
From doing some research, I know that the way my implementation works today
is not thread-safe, because...
|
by: Grant |
last post by:
I am having great difficulty understanding this and any code samples I find
online are kilometres long and complicated to understand...Please could
someone give me a simple exampe of how to get a delegate passed to my worked
class so that my main form can update its progress bar? I know it has
something to do with begininvoke and endinvoke...
|
by: Pavils Jurjans |
last post by:
(I am sorry to crosspost both here and in asp.net group. I think, this
question quite certainly belongs better to this group, but by error I posted
the question to asp.net group)
Hello,
I am reading the article
http://msdn.microsoft.com/msdnmag/issues/04/01/BasicInstincts/ , and, since
the sample code is VB.NET, I am wondering what the...
|
by: =?Utf-8?B?RGVubmlz?= |
last post by:
I am trying to set a property of a control from a thread started from the UI
thread using Delegates. I can set the property directly in the thread if I
set the form's CheckForIllegalCrossThreadCalls property to False. However, I
don't want to do that so I am trying to use Delegates and the control's
invoke method.
Any suggestions on how...
| |
by: =?Utf-8?B?T2xkQ2FEb2c=?= |
last post by:
My question is regarding the use of delegates in C#. I see how .Net uses
delegates to wire event handlers to events. It’s an object created by a
single line of code by the system and that makes perfect sense to me. I
understand that there is a lot of code underneath that the system has created
that makes it all work, thereby making it...
|
by: Tem |
last post by:
I've read every example i could find on the subject and still couldn't
figure out its proper usage.
What's the point of delegates, why can't I just invoke the method
directly???
Can someone please help?
Tem
|
by: tshad |
last post by:
I have a set up javascript functions that pass function pointers and I am
trying to figure out how to do the same thing in C# using delegates.
// We define some simple functions here
function add(x,y) {return x + y;}
function subtract(x,y) {return x - 1; }
function multiply(x,y) {return x * 1; }
|
by: raylopez99 |
last post by:
They usually don't teach you in most textbooks I've seen that
delegates can be used to call class methods from classes that are
'unaware' of the delegate, so long as the class has the same signature
for the method (i.e., as below, int Square (int)).
Here is an example to show that feature. Note class "UnAwareClass"
has its methods Square...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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...
|
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...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |