473,385 Members | 2,044 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,385 software developers and data experts.

how does c# know that there are indexers an an IL assembly ?

Hello,

IL does not have indexers. Infact the c# compiler compiles indexers to
Set_Item and Get_Item (or whatever name I choose via the
IndexerNameAttribute ).
So how does c# (compiler) know that something in a IL Assembly is supposed
to be an indexer ?
And more important, what ways do I have to influence that ?
Nov 16 '05 #1
5 1902
bonk,

I believe that the compiler first looks for the property with the
IndexerNameAttribute. Failing that, I think it will then look for a
property which has the name "Item" (I am pretty shaky on this, but it's the
most prominent thought in my mind right now on the subject).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bonk" <sc******************@gmx.de> wrote in message
news:eL**************@TK2MSFTNGP12.phx.gbl...
Hello,

IL does not have indexers. Infact the c# compiler compiles indexers to
Set_Item and Get_Item (or whatever name I choose via the
IndexerNameAttribute ).
So how does c# (compiler) know that something in a IL Assembly is supposed
to be an indexer ?
And more important, what ways do I have to influence that ?

Nov 16 '05 #2
Well, that sounds somhow strange to me. Also there is a
PropertyInfo.GetIndexParameters Method.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:Oz**************@TK2MSFTNGP10.phx.gbl...
bonk,

I believe that the compiler first looks for the property with the
IndexerNameAttribute. Failing that, I think it will then look for a
property which has the name "Item" (I am pretty shaky on this, but it's
the most prominent thought in my mind right now on the subject).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bonk" <sc******************@gmx.de> wrote in message
news:eL**************@TK2MSFTNGP12.phx.gbl...
Hello,

IL does not have indexers. Infact the c# compiler compiles indexers to
Set_Item and Get_Item (or whatever name I choose via the
IndexerNameAttribute ).
So how does c# (compiler) know that something in a IL Assembly is
supposed to be an indexer ?
And more important, what ways do I have to influence that ?


Nov 16 '05 #3
bonk,

Why would it be strange? And the GetIndexParameters method is only
going to return the parameters for the property if it is an indexer.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bonk" <sc******************@gmx.de> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Well, that sounds somhow strange to me. Also there is a
PropertyInfo.GetIndexParameters Method.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:Oz**************@TK2MSFTNGP10.phx.gbl...
bonk,

I believe that the compiler first looks for the property with the
IndexerNameAttribute. Failing that, I think it will then look for a
property which has the name "Item" (I am pretty shaky on this, but it's
the most prominent thought in my mind right now on the subject).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bonk" <sc******************@gmx.de> wrote in message
news:eL**************@TK2MSFTNGP12.phx.gbl...
Hello,

IL does not have indexers. Infact the c# compiler compiles indexers to
Set_Item and Get_Item (or whatever name I choose via the
IndexerNameAttribute ).
So how does c# (compiler) know that something in a IL Assembly is
supposed to be an indexer ?
And more important, what ways do I have to influence that ?



Nov 16 '05 #4
Could it be possible that information about indexers are stored somwhere in
the metadata ?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:eG**************@tk2msftngp13.phx.gbl...
bonk,

Why would it be strange? And the GetIndexParameters method is only
going to return the parameters for the property if it is an indexer.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bonk" <sc******************@gmx.de> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Well, that sounds somhow strange to me. Also there is a
PropertyInfo.GetIndexParameters Method.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
schrieb im Newsbeitrag news:Oz**************@TK2MSFTNGP10.phx.gbl...
bonk,

I believe that the compiler first looks for the property with the
IndexerNameAttribute. Failing that, I think it will then look for a
property which has the name "Item" (I am pretty shaky on this, but it's
the most prominent thought in my mind right now on the subject).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bonk" <sc******************@gmx.de> wrote in message
news:eL**************@TK2MSFTNGP12.phx.gbl...
Hello,

IL does not have indexers. Infact the c# compiler compiles indexers to
Set_Item and Get_Item (or whatever name I choose via the
IndexerNameAttribute ).
So how does c# (compiler) know that something in a IL Assembly is
supposed to be an indexer ?
And more important, what ways do I have to influence that ?



Nov 16 '05 #5
I Ialways assumed that Reflections are evaluating metadata ...

"bonk" <sc******************@gmx.de> schrieb im Newsbeitrag
news:eL**************@TK2MSFTNGP12.phx.gbl...
Hello,

IL does not have indexers. Infact the c# compiler compiles indexers to
Set_Item and Get_Item (or whatever name I choose via the
IndexerNameAttribute ).
So how does c# (compiler) know that something in a IL Assembly is supposed
to be an indexer ?
And more important, what ways do I have to influence that ?

Nov 16 '05 #6

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

Similar topics

12
by: Sergey Klementiev | last post by:
Why it's impossible to have a static indexer in C#?
3
by: DKode | last post by:
Ok, Consider the following example: School Class - StudentCollection Property StudentCollection Class : CollectionBase - Add - Item
8
by: Russell Bearden | last post by:
Why are there no indexed properties in C#? For example: class blah { public Node Child { get {
6
by: Pete Davis | last post by:
I'm writing an XML serializer (similar to the MS XMLSerializer). It uses reflection to get the values from a class/struct. The one area I'm confused on is indexers. I can get the indexer...
5
by: Rashad Rivera | last post by:
I need to know why the Application_Start function fires twice when it initializes. It is doing double work and messing up my process. Thanks for your help - Rashad
3
by: Richard Lewis Haggard | last post by:
I'm getting an error that should be easy but I don't understand the info structure well enough to know what's going wrong. I've been slowly adding classes and projects to a solution for a while....
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
7
by: Tom Dacon | last post by:
I'm using Reflection to iterate over the properties and fields of an arbitrary object. For non-indexed properties it's pi.GetValue(theObject, Nothing) for VB, or pi.GetValue(theObject, null) for...
5
by: Polaris431 | last post by:
I notice that the Dataset designer generates code for properties that look like this: public string ID { get { try { return ((string) (this)); } catch (System.InvalidCastException e) {
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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
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.