473,748 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cach ing.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.Cac hing.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 1694
Check this link out, it explains indexers in detail.

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

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Dotnetjunk y" <do*********@no reply.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.Cach ing.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.Cac hing.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

"Dotnetjunk y" <do*********@no reply.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.Cach ing.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.Cac hing.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.mach in AT dot.state.fl.us > wrote in message
news:O2******** ******@TK2MSFTN GP12.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

"Dotnetjunk y" <do*********@no reply.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.Cach ing.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.Cac hing.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
1510
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 hold only integers. Even with Objects, they seem to be readonly. I can't assign values to them. <Bindable(True), Category("Data"), DefaultValue("Item")> Property () As ArrayList
9
8014
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 search Set objFindResults = objApp.ActiveMap.FindAddressResults("One Microsoft Way", "Redmond", , "WA", , geoCountryUnitedStates) MsgBox "The first item in the find list is: " _ + objFindResults.Item(1).Name
3
5495
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 available (using object browser). Has anything changed? Online Doc URL:
4
12231
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(); System.Data.DataTable datatable1 = new System.Data.DataTable("table1");
6
1157
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 should I do this? I need the value of the field TP_Name of the selected row (just put 2 there for now) . I found another msg on usegroups with the same question but no answer.
4
1406
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 help file I guess speed and that's a good thing but what is the point when if you use "for each ... next" the Item property is NOT used. Surely most collections are accessed via "for each ... next" as opposed to "for nItem = 0 to nItems". Am I...
5
1587
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 as my pattern. Two particular things stand out: public abstract XmlNode Item(int i); and
5
2974
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 IntelliSense. What is wrong here?
2
3053
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. What am I not understanding? -- Regards,
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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,...
0
9562
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...
1
9333
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
8255
agi2029
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...
1
6799
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
6078
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
4608
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...
3
2217
bsmnconsultancy
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...

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.