473,385 Members | 1,392 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.

Item property and indexer

Hi,

I'm really get confused on this issue. Hope that someone can help me get
clear after this post.

Take the class System.Web.Caching.Cache for example. In the documentation,
there's a property called Item and the description is:

"Gets or sets the cache item at the specified key. In C#, this property is
the indexer for the Cache class."

But when I tried to access this property, using Cache.Item["keyVaule"], the
compiler complains:

'System.Web.Caching.Cache' does not contain a definition for 'Item'

Can someone explain this strange behavior to me ?

Thanks a lot.

--
Dotnetjunky

Nov 15 '05 #1
4 1682
Check this link out, it explains indexers in detail.

http://www.csharp-station.com/Tutorials/Lesson11.aspx

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Dotnetjunky" <do*********@noreply.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I'm really get confused on this issue. Hope that someone can help me get
clear after this post.

Take the class System.Web.Caching.Cache for example. In the documentation,
there's a property called Item and the description is:

"Gets or sets the cache item at the specified key. In C#, this property is
the indexer for the Cache class."

But when I tried to access this property, using Cache.Item["keyVaule"], the compiler complains:

'System.Web.Caching.Cache' does not contain a definition for 'Item'

Can someone explain this strange behavior to me ?

Thanks a lot.

--
Dotnetjunky

Nov 15 '05 #2
Hi,

In these cases where the doc say that the property X is the indexer you
access it without the property name, the compiler knows how to find it,
cause it's the indexer.

you access it using Cache["key"] you do not have to use the .Item
construction.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dotnetjunky" <do*********@noreply.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I'm really get confused on this issue. Hope that someone can help me get
clear after this post.

Take the class System.Web.Caching.Cache for example. In the documentation,
there's a property called Item and the description is:

"Gets or sets the cache item at the specified key. In C#, this property is
the indexer for the Cache class."

But when I tried to access this property, using Cache.Item["keyVaule"], the compiler complains:

'System.Web.Caching.Cache' does not contain a definition for 'Item'

Can someone explain this strange behavior to me ?

Thanks a lot.

--
Dotnetjunky

Nov 15 '05 #3
So, my question is why the doc shows the Item property ?
Is it correct that the Item property is only for other languages, but not C#
?

--
Dotnetjunky
"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
Hi,

In these cases where the doc say that the property X is the indexer you
access it without the property name, the compiler knows how to find it,
cause it's the indexer.

you access it using Cache["key"] you do not have to use the .Item
construction.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dotnetjunky" <do*********@noreply.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I'm really get confused on this issue. Hope that someone can help me get
clear after this post.

Take the class System.Web.Caching.Cache for example. In the documentation, there's a property called Item and the description is:

"Gets or sets the cache item at the specified key. In C#, this property is the indexer for the Cache class."

But when I tried to access this property, using Cache.Item["keyVaule"],

the
compiler complains:

'System.Web.Caching.Cache' does not contain a definition for 'Item'

Can someone explain this strange behavior to me ?

Thanks a lot.

--
Dotnetjunky


Nov 15 '05 #4
Is it correct that the Item property is only for other languages, but not C#?


Yes

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #5

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

Similar topics

1
by: Wael | last post by:
Hi, I created a custom control, but I can't add an item property to it. I tried the code below, but when I click the property, it shows a list of Objects. I can't figure out how to have items to...
9
by: Gerald Lightsey | last post by:
I am doing some work that involves automating MS MapPoint 2002. The object model is documented in the context of Visual Basic 6.0. A typical example follows. 'Output first result of find...
3
by: Fernando Chilvarguer | last post by:
Hi On Microsoft documentation (both on my MSDN library localy and online) the System.Collections.ArrayList class contains a Item property. When I try to use it I can't see that property...
4
by: Marc van den Bogaard | last post by:
hello together, my datarow.item property is missing, i just can accesss the ItemArray property, what is wrong with this? System.Data.DataSet dataset1 = new System.Data.DataSet(); ...
6
by: Stijn Verrept | last post by:
I found several code examples on the net but this doesn't want to work. Label2.Text = filesIDData1.Tables.Rows.Item; There isn't a Item property in C# while all the examples have one. How...
4
by: Tim Murphy | last post by:
When creating a collection class that inherits CollectionBase what advantage is there for the Item property returning CType(List.Item(index), <objecttype> ) over List.Item(index). Looking at the...
5
by: Jeremy McPeak | last post by:
I am writing a collection. I downloaded the Rotor kit and started looking at how the classes in System.Xml are written and am using them as a guide. For my collection, I thought I'd use XmlNodeList...
5
by: Vik | last post by:
I used to work in VB.NET. Now in C#, I have: using System; using System.Data; using System.Data.SqlClient; DataRow dr; Then I want to use dr("ColName") but there is no Item property in the...
2
by: GaryDean | last post by:
The docs say that the DataRow class has an Item property so I could set a value without having to know the column name i.e. myDR.Item = myString; but, there is no Item property in the DataRow. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
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...

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.