Hi,
C# 3.0 extension methods become useful for us. Do we have the similar
concept for extension properties?
Thank you,
Max 26 2852
On Wed, 23 Jul 2008 15:42:19 -0700, Max2006 <al*******@news group.nospam>
wrote:
C# 3.0 extension methods become useful for us. Do we have the similar
concept for extension properties?
No, I don't think so. But interesting idea. Maybe they're thinking about
it.
Max2006 wrote:
C# 3.0 extension methods become useful for us. Do we have the similar
concept for extension properties?
No.
And there is a syntax problem.
Properties are distinguished from methods by the fact that they
do not have an argument list.
The object being extended is passed as an extra argument.
How should the syntax be to distinguish between
a method with no arguments and a property ?
Arne
On Wed, 23 Jul 2008 17:11:48 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
[...]
How should the syntax be to distinguish between
a method with no arguments and a property ?
Syntax for an extension property:
public int MyProperty(this SomeClass arg0)
{
get;
set;
}
Just because properties as declared now don't include an argument list,
that doesn't mean they couldn't. There's enough other information in the
declaration block to distinguish a property from a method, I believe.
No doubt there are other valid ways to allow the declaration of an
extension property, but the above seems most straightforward and
consistent to me.
Pete
Peter Duniho wrote:
On Wed, 23 Jul 2008 17:11:48 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
>How should the syntax be to distinguish between a method with no arguments and a property ?
Syntax for an extension property:
public int MyProperty(this SomeClass arg0)
{
get;
set;
}
Just because properties as declared now don't include an argument list,
that doesn't mean they couldn't. There's enough other information in
the declaration block to distinguish a property from a method, I believe.
No doubt there are other valid ways to allow the declaration of an
extension property, but the above seems most straightforward and
consistent to me.
It will require readers to check the body to see if something is
a method or a property.
Not very nice syntax.
Arne
On Wed, 23 Jul 2008 17:59:45 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
It will require readers to check the body to see if something is
a method or a property.
Not very nice syntax.
I don't personally see the big deal. But if you don't like that, how
about this:
public int MyProperty
{
this SomeClass arg0;
get;
set;
}
Or provide your own suggestion. Complaining that it can't be done because
of a syntax problem is dumb. That's what we pay the language designers
the big bucks for. Let them figure it out and come up with something that
is reasonably elegant and makes life easy for the compiler writer, if
that's so important.
Pete
On Jul 24, 12:22*am, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
C# 3.0 extension methods become useful for us. Do we have the similar *
concept for extension properties?
No, I don't think so. *But interesting idea. *Maybe they're thinking about *
it.
It's definitely been considered. I don't know whether it's actually
going to be in C# 4 or not. (I'm looking forward to a first proper
peek at C# 4, whenever that happens. I expect it to be a much smaller
set of changes than either 2 or 3 though.)
Jon
Jon Skeet [C# MVP] wrote:
On Jul 24, 12:22 am, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
>>C# 3.0 extension methods become useful for us. Do we have the similar concept for extension properties?
No, I don't think so. But interesting idea. Maybe they're thinking about it.
It's definitely been considered. I don't know whether it's actually
going to be in C# 4 or not. (I'm looking forward to a first proper
peek at C# 4, whenever that happens. I expect it to be a much smaller
set of changes than either 2 or 3 though.)
I think the C# team, IF they implement extension properties, should
take that famous step back and look again at what the REAL reason is
people want extension properties (as they represent state): AOP. So they
should use their influence to turn the CLR team over to implement AOP at
the CLR level once and for all.
FB
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Peter Duniho wrote:
On Wed, 23 Jul 2008 17:59:45 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
>It will require readers to check the body to see if something is a method or a property.
Not very nice syntax.
I don't personally see the big deal. But if you don't like that, how
about this:
public int MyProperty
{
this SomeClass arg0;
get;
set;
}
Or provide your own suggestion. Complaining that it can't be done
because of a syntax problem is dumb. That's what we pay the language
designers the big bucks for. Let them figure it out and come up with
something that is reasonably elegant and makes life easy for the
compiler writer, if that's so important.
Heh :)
I think this syntax is parsable, the other is very hard to do, as it
requires a looooooong look ahead.
Nevertheless, there's a practical problem as well: Extension methods
are static, i.e. don't have state, they work on the object passed in.
However, a property represents state, on the object they're a part of.
An extension property therefore should be static, but ... what should
that 'set' do? set a property on arg0? Then why not set the property
directly instead of calling this extension property?
FB
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
On Jul 24, 8:53*am, "Frans Bouma [C# MVP]"
<perseus.usenet NOS...@xs4all.n lwrote:
It's definitely been considered. I don't know whether it's actually
going to be in C# 4 or not. (I'm looking forward to a first proper
peek at C# 4, whenever that happens. I expect it to be a much smaller
set of changes than either 2 or 3 though.)
* * * * I think the C# team, IF they implement extension properties, should
take that famous step back and look again at what the REAL reason is
people want extension properties (as they represent state): AOP. So they
should use their influence to turn the CLR team over to implement AOP at
the CLR level once and for all.
I don't immediately see the AOP connection, but I'm sure you're right
- could you elaborate?
I see extension properties as a way of providing different views on
existing state.
Jon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: WindAndWaves |
last post by:
Hi Gurus
I am just putting my first PHP site together...
One thing that I think it strange is that I do not seem to be able to view
the source. It is almost like the page does not load properly...
If you like then I can email you the source code, but I thought that this
may be a problem that occurs frequently...
|
by: Carl Ogawa |
last post by:
How do I make .cgi extention work?
I installed ActivePerl 5.8. My CGI scripts work fine with .PL extention but
not .CGI extention although I associated CGI extention as exactly same as PL
extention in WinXP Prof . Where else should I
change to make it work?
|
by: Tuvas |
last post by:
I am currently writing an extention module that needs to recieve a list
of characters that might vary in size from 0 to 8. This is written as a
list of characters rather than a string because it's easier to
manipulate. However, when I pass this list of characters into the
extention module, it keeps giving errors. Is there a way to do one of
the following?
A. Change a list of chars to a single string or
B. Read a list of chars in an...
|
by: Tuvas |
last post by:
I am in the process of writing an extention module, and am coming up
with lots of problems. Perhaps someone could be of use. I keep getting
data that isn't what I'm sending the program. Let me give the line of C
code and Python Code and output to illistrate the problem.
write_can(can_han,0x0140,'abcd')
if (PyArg_ParseTuple(args("iiz#",&can_han,&com,&data,&len)
return NULL;
|
by: James Radke |
last post by:
Hello,
I have a multithreaded windows NT service application (vb.net 2003) that I
am working on (my first one), which reads a message queue and creates
multiple threads to perform the processing for long running reports. When
the processing is complete it uses crystal reports to load a template file,
populate it, and then export it to a PDF.
It works fine so far....
| |
by: Howard |
last post by:
how do i change the file extention of asp.net file?
ie. from .aspx to .mspx
|
by: ghighi |
last post by:
Hello, Il a downloading a file from a download.aspx page with that
code:
-----------------------------------------------------------------------------------------
string fileName = Request.Params;
string fileExtension=fileName.Substring(fileName.Length-3);
string filePath = Path.Combine( "apath",fileName);
FileStream fs = new FileStream(filePath,
FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
|
by: anandansv |
last post by:
When i try to install .Net2003 in Win2000 Professional is gives an warning message
"Frontpage 2002 server Extention " is not configure.
How to configure that/
|
by: godfather96 |
last post by:
I am using a web control called eXml which is an extention to ms xml web control which supports xslt 2.0
when trying to group elements i receive the following error:
group-by is not a valid extention element
is there a namespace or something a need to add.
my source is below
|
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: 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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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: 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...
| |