Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2006

Tip: Looking for answers? Try searching our database.

DataRow and Item

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vik - 29 Jun 2006 19:09 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.