473,851 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
IndexerNameAttr ibute ).
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 1935
bonk,

I believe that the compiler first looks for the property with the
IndexerNameAttr ibute. 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.co m

"bonk" <sc************ ******@gmx.de> wrote in message
news:eL******** ******@TK2MSFTN GP12.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
IndexerNameAttr ibute ).
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.Ge tIndexParameter s Method.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> schrieb
im Newsbeitrag news:Oz******** ******@TK2MSFTN GP10.phx.gbl...
bonk,

I believe that the compiler first looks for the property with the
IndexerNameAttr ibute. 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.co m

"bonk" <sc************ ******@gmx.de> wrote in message
news:eL******** ******@TK2MSFTN GP12.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
IndexerNameAttr ibute ).
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 GetIndexParamet ers 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.co m

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

I believe that the compiler first looks for the property with the
IndexerNameAttr ibute. 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.co m

"bonk" <sc************ ******@gmx.de> wrote in message
news:eL******** ******@TK2MSFTN GP12.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
IndexerNameAttr ibute ).
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.c om> schrieb
im Newsbeitrag news:eG******** ******@tk2msftn gp13.phx.gbl...
bonk,

Why would it be strange? And the GetIndexParamet ers 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.co m

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

I believe that the compiler first looks for the property with the
IndexerNameAttr ibute. 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.co m

"bonk" <sc************ ******@gmx.de> wrote in message
news:eL******** ******@TK2MSFTN GP12.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
IndexerNameAttr ibute ).
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******** ******@TK2MSFTN GP12.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
IndexerNameAttr ibute ).
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
24831
by: Sergey Klementiev | last post by:
Why it's impossible to have a static indexer in C#?
3
2315
by: DKode | last post by:
Ok, Consider the following example: School Class - StudentCollection Property StudentCollection Class : CollectionBase - Add - Item
8
1588
by: Russell Bearden | last post by:
Why are there no indexed properties in C#? For example: class blah { public Node Child { get {
6
2573
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 PropertyInfo and the ParameterInfo stuff, but I can't possibly know the range of valid values nor what the underlying storage is. How is this normally handled? Should I just ignore the indexer and simply serialize the fields?
5
2832
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
2563
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. There's a single test exe and a number of of# library classes. I needed to move two of the projects down one directory from their original position and did so my making the appropriate directory, copying the source to that directory, deleting the...
3
4419
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 really understand how this could be an issue. The assemblies that the system is complaining about are ones that we build here and we're not changing version numbers on anything. The errors come and go with no apparent rhyme or reason. We do not...
7
16584
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 C# For indexed properties, instead of Nothing (null) you pass an array of index values. OK, no problem so far.
5
1513
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
11011
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10670
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 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...
1
10725
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,...
0
10352
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 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...
1
7900
isladogs
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...
0
7072
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();...
0
5735
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...
1
4547
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
2
4142
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.