473,491 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What's up with C#?

I'm a VB.net programmer currently battling to build new apps in C#, and MAN!
It's been a bit frustrating, to say the least.

I've done quite a bit of progamming with Java and C back in the day, so I
can deal with the case sensitiviness and semicolens, but I'm finding certain
aspects of the language to be a real pain.

Well, to get to the point, here's a problem that I'd appreciate it if
someone could help me...

Note: dsResponse is a dataset being populated by an xml file.

In code, I have the following:
//This works:
if (dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString()
== "Fail")

//This doesn't work
if (dsResponse.ReservationResponse.Rows[0].ItemArray["Status"] == "Fail")
error: Cannot implicitly convert type 'string' to 'int'

In the command window:
//this works
dsResponse.ReservationResponse.Rows[0].ItemArray["Status"]

//this DOESN'T:
dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString()
Error:
'dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0.ToString' does
not exist

What I would like to accomplish is to be able to use the NAME of the field,
and not the index value, to retrieve the value of that item.

WHAT GIVES?

tia
Jul 21 '05 #1
2 2942
tuuky <tu***@discussions.microsoft.com> wrote:
I'm a VB.net programmer currently battling to build new apps in C#, and MAN!
It's been a bit frustrating, to say the least.

I've done quite a bit of progamming with Java and C back in the day, so I
can deal with the case sensitiviness and semicolens, but I'm finding certain
aspects of the language to be a real pain.

Well, to get to the point, here's a problem that I'd appreciate it if
someone could help me...

Note: dsResponse is a dataset being populated by an xml file.

In code, I have the following:
//This works:
if (dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString()
== "Fail")

//This doesn't work
if (dsResponse.ReservationResponse.Rows[0].ItemArray["Status"] == "Fail")
error: Cannot implicitly convert type 'string' to 'int'
Indeed, because you can't index an array (ItemArray) by string. I don't
know why you're using the ItemArray property anyway though - why not
just use the indexer on the row itself?
In the command window:
//this works
dsResponse.ReservationResponse.Rows[0].ItemArray["Status"]
That sounds very odd. Are you sure you don't mean

dsResponse.ReservationResponse.Rows[0]["Status"]

?
//this DOESN'T:
dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString()
Error:
'dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0.ToString' does
not exist

What I would like to accomplish is to be able to use the NAME of the field,
and not the index value, to retrieve the value of that item.


So use

if (dsResponse.ReservationResponse.Rows[0]["Status"]=="Fail")
{
....
}

No problem.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Thanks a lot, Jon.

Part of the growing pains, I guess.

"Jon Skeet [C# MVP]" wrote:
tuuky <tu***@discussions.microsoft.com> wrote:
I'm a VB.net programmer currently battling to build new apps in C#, and MAN!
It's been a bit frustrating, to say the least.

I've done quite a bit of progamming with Java and C back in the day, so I
can deal with the case sensitiviness and semicolens, but I'm finding certain
aspects of the language to be a real pain.

Well, to get to the point, here's a problem that I'd appreciate it if
someone could help me...

Note: dsResponse is a dataset being populated by an xml file.

In code, I have the following:
//This works:
if (dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString()
== "Fail")

//This doesn't work
if (dsResponse.ReservationResponse.Rows[0].ItemArray["Status"] == "Fail")
error: Cannot implicitly convert type 'string' to 'int'


Indeed, because you can't index an array (ItemArray) by string. I don't
know why you're using the ItemArray property anyway though - why not
just use the indexer on the row itself?
In the command window:
//this works
dsResponse.ReservationResponse.Rows[0].ItemArray["Status"]


That sounds very odd. Are you sure you don't mean

dsResponse.ReservationResponse.Rows[0]["Status"]

?
//this DOESN'T:
dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString()
Error:
'dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0.ToString' does
not exist

What I would like to accomplish is to be able to use the NAME of the field,
and not the index value, to retrieve the value of that item.


So use

if (dsResponse.ReservationResponse.Rows[0]["Status"]=="Fail")
{
....
}

No problem.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #3

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

Similar topics

5
3445
by: Al Davis | last post by:
Note: I tried cross-posting this message to several newsgoups, including comp.lang.perl.misc, c.l.p.moderated, comp.infosystems.www.authoring.cgi, comp.lang.javascript and comp.lang.php. Nothing...
2
3050
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is...
220
18799
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
54
6497
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
3
2976
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a...
92
6325
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
137
6921
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
125
14532
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
121
9898
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
8
3117
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that...
0
7154
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,...
0
7190
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...
1
6858
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...
0
7360
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...
0
5451
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,...
0
3086
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...
0
1392
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 ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
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...

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.