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?
Thanks.
Marina Levit [MVP] - 29 Jun 2006 19:12 GMT
Why do you need the Item property exactly?
>I used to work in VB.NET. Now in C#, I have:
> using System;
[quoted text clipped - 7 lines]
>
> Thanks.
sloan - 29 Jun 2006 19:28 GMT
"Item" is the indexer in vb.net.
the default value of c# ~~is the indexer. so your code would look like
this... (aka, you don't have to type in "Item")
myobject.Item(0) --vb.net
myobject[0] // c#
> I used to work in VB.NET. Now in C#, I have:
> using System;
[quoted text clipped - 7 lines]
>
> Thanks.
Michael - 29 Jun 2006 19:30 GMT
Indexers are accessed in C# by brackets, not parenthesis. Could this be part
of your problem with Intellisense?
dr["ColName"]
>I used to work in VB.NET. Now in C#, I have:
> using System;
[quoted text clipped - 7 lines]
>
> Thanks.
Nicholas Paldino [.NET/C# MVP] - 29 Jun 2006 19:34 GMT
Vik,
In C#, you use an indexer. You would do this:
dr["ColName"]
Hope this helps.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
>I used to work in VB.NET. Now in C#, I have:
> using System;
[quoted text clipped - 7 lines]
>
> Thanks.
Vik - 30 Jun 2006 15:59 GMT
Thanks for the replies.
Yes, the problem was that I used VB style dr(...) instead of dr[...].
In VB, an object's default property is listed in IntelliSense. In C#, an
indexer is never shown in IntelliSense?
Vik