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

Please Help: Expression Classifications

Hi all,

Can someone please elaborate on (or annotate) this text excerpt I found
while reading "The C# Programming Language", by Anders Hejlsberg, Scott
Wiltamuth, Peter Golde:

Section 7.1
A property access:
Every property access has an associated type, namely the type of the
property. Furthermore, a property access may have an associated
instance expression. {up to this it is clear}. When an accessor (the
get or set block) of an instance property access is invoked, the result
of evaluating the instance expression becomes the instance represented
by this. {this last statement is not clear - my understanding is: the
result is a value with type the type of the property.}

Thanks in advance.

Dec 6 '06 #1
2 1101
muler wrote:
Hi all,

Can someone please elaborate on (or annotate) this text excerpt I found
while reading "The C# Programming Language", by Anders Hejlsberg, Scott
Wiltamuth, Peter Golde:
Not read it, so there might be context I'm missing, but I'll have a go.
>
Section 7.1
A property access:
Every property access has an associated type, namely the type of the
property. Furthermore, a property access may have an associated
instance expression. {up to this it is clear}.
OK.
When an accessor (the
get or set block) of an instance property access is invoked, the result
of evaluating the instance expression becomes the instance represented
by this. {this last statement is not clear - my understanding is: the
result is a value with type the type of the property.}
I think what it means is: In the code for a property accessor (whether
get or set), the keyword 'this' refers to that particular instance whose
property is being accessed.

Is the final 'this' in a different font in the original text, perhaps
the font used for code?

Example (air code):

class Foo
{
int _halfbar;
public int Bar
{
get { return this._halfbar * 2; }
set { this._halfbar = value / 2; }
}

public static void Main(string[] args)
{
Foo foo1 = new Foo();
Foo foo2 = new Foo();

foo1.Bar = 6;
foo2.Bar = 3;

Console.WriteLine("foo2.Bar is {0}", foo2.Bar.ToString());

return;
}
}

Here, the 'this' in the code for Foo.Bar refers successively to the
instance referred to by foo1, the instance referred to by foo2, and the
instance referred to by foo1.

Without knowing the structure of the book, I couldn't say how plausible
this relatively simple explanation is for this section of the book.
--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Dec 6 '06 #2
muler wrote:
Section 7.1
A property access:
Every property access has an associated type, namely the type of the
property. Furthermore, a property access may have an associated
instance expression. {up to this it is clear}. When an accessor (the
get or set block) of an instance property access is invoked, the result
of evaluating the instance expression becomes the instance represented
by this. {this last statement is not clear - my understanding is: the
result is a value with type the type of the property.}
Larry is perfectly correct - the last sentence is just saying that the
"instance expression" acts like any other method of the class, and
`this. Whatever` refers to the Whatever instance member. (My copy (2e)
has a reference to 7.5.7, "this Access."

--

..NET 2.0 for Delphi Programmers
www.midnightbeach.com/.net
What you need to know.
Dec 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Balaji | last post by:
import __main__ tempbuffer= None permbuffer={} class E: def __init__(self): # print id(self) self.hasVar = False
6
by: Allan | last post by:
Please help, below is my problem. Let's say I have 2 tables, a Products table and a Colors table that go as follow: Table Products prodID Name 1 shirt 2 tshirt
2
by: jerry.xuddd | last post by:
Hi, I have a xml file like this <tab> <category name="Software" > Test purpose <subcategory name="Software"> <method url="addSoftware.aspx">Add</method> <method...
5
by: alkapin | last post by:
I am trying to clean up a city name. Inside the letters only one of 3 characters (dot, space and hyphen) is allowed (1 max). For example: Los-Angeles,Los Angeles and N.Westminster are ok. Outside...
4
by: sasifiqbal | last post by:
Hi All, I have following text Template that needs to be parsed using Regular Expression -- Test Template This is a Test Template for <#OrderNumber/> Sender Message is <#SENDERMESSAGE/>
1
by: wctins | last post by:
I can't figure it out and I know is a simple issue, please help me! The message error: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' Syntax error (missing operator) in query...
1
by: mohsin | last post by:
hi everyone well i m little bit confused about the use of pre an post increment infact my thinking contradict with the logic of programe lets consider an example x=5; y=x++; z=x; after the...
14
by: leanne123my | last post by:
Hi, I have some problem with my Microsoft Access 2003 coding. Can any expert please help to check out the problem and provide me the solution? I have a Order_form, I need to update the...
4
by: rajesh619 | last post by:
I'm new to programming. I have created a servlet which retrieves values from the database after a value is put into the HTML page to which it is attached. But during compilation, it shows two errors....
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
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...

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.