473,396 Members | 1,749 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,396 software developers and data experts.

> works but = doesn't

If I use the following clause in my code I get two errors on this line.

if (dsFacultyBio.Tables[strTable].Rows.Count = 0)

The errors are

C:\DEV QX C#\6.4.1\QX.Data\QXFaculty.cs(318): Cannot implicitly convert type
'int' to 'bool'
and

C:\DEV QX C#\6.4.1\QX.Data\QXFaculty.cs(318): Property or indexer
'System.Data.InternalDataCollectionBase.Count' cannot be assigned to -- it
is read only
BUT!!!! If I change the = sign to a sign, it works fine. This works
fine.

if (dsFacultyBio.Tables[strTable].Rows.Count 0)

What should I be doing to make this work with the equality?

tia

las
Oct 4 '06 #1
4 1425
Laurel <Fa******@hotmail.comwrote:
If I use the following clause in my code I get two errors on this line.

if (dsFacultyBio.Tables[strTable].Rows.Count = 0)
Should be:

if (dsFacultyBio.Tables[strTable].Rows.Count == 0)

Note the double equals.

HTH

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1
Oct 4 '06 #2
"Laurel" <Fa******@Hotmail.comwrote in message
news:uj***************@TK2MSFTNGP06.phx.gbl...
What should I be doing to make this work with the equality?
Use the correct operator, in this case == (double equals)
Oct 4 '06 #3

Laurel wrote:
If I use the following clause in my code I get two errors on this line.

if (dsFacultyBio.Tables[strTable].Rows.Count = 0)

The errors are

C:\DEV QX C#\6.4.1\QX.Data\QXFaculty.cs(318): Cannot implicitly convert type
'int' to 'bool'
and

C:\DEV QX C#\6.4.1\QX.Data\QXFaculty.cs(318): Property or indexer
'System.Data.InternalDataCollectionBase.Count' cannot be assigned to -- it
is read only
BUT!!!! If I change the = sign to a sign, it works fine. This works
fine.

if (dsFacultyBio.Tables[strTable].Rows.Count 0)

What should I be doing to make this work with the equality?
In all of the C-like languages (C, C++, Java, C#), a single = indicates
assignment. An equality comparison is ==.

That means that the compiler read what you wrote as: "Assign 0 to
dsFacultyBio.Tables[strTable].Rows.Count, then use the assignment
result (0) as a boolean condition in the "if" statement." Thus the two
messages.

Oct 4 '06 #4
Thanks for the explanation. Somewhere along the line I thought == applied
to strings.

"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
>
Laurel wrote:
>If I use the following clause in my code I get two errors on this line.

if (dsFacultyBio.Tables[strTable].Rows.Count = 0)

The errors are

C:\DEV QX C#\6.4.1\QX.Data\QXFaculty.cs(318): Cannot implicitly convert
type
'int' to 'bool'
and

C:\DEV QX C#\6.4.1\QX.Data\QXFaculty.cs(318): Property or indexer
'System.Data.InternalDataCollectionBase.Count' cannot be assigned to --
it
is read only
BUT!!!! If I change the = sign to a sign, it works fine. This works
fine.

if (dsFacultyBio.Tables[strTable].Rows.Count 0)

What should I be doing to make this work with the equality?

In all of the C-like languages (C, C++, Java, C#), a single = indicates
assignment. An equality comparison is ==.

That means that the compiler read what you wrote as: "Assign 0 to
dsFacultyBio.Tables[strTable].Rows.Count, then use the assignment
result (0) as a boolean condition in the "if" statement." Thus the two
messages.

Oct 4 '06 #5

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

Similar topics

4
by: edg | last post by:
This works: $b = $a->method1(); $c = $b->method2(); I'd like to get this all on one expression, something like: $c = ${$a->method1()}->method2(); which doesn't work.
3
by: Jens Kristensen | last post by:
I have a problem displaying a divbox containing a html-textarea - everything works fine with "normal" characters. However, when the textarea contains special chars like <P> or ' , the box fails to...
34
by: Mark Moore | last post by:
It looks like there's a pretty serious CSS bug in IE6 (v6.0.2800.1106). The HTML below is validated STRICT HTML 4.01 and renders as I would expect in Opera, FrontPage, and Netscape. For some...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
6
by: Eric Layman | last post by:
Hi, I have fields from textareas. With a click of a button, php is able to grab these fields and by using header(), convert the output to Ms Word doc. But the outcome of the word doc...
5
by: David Longnecker | last post by:
I'm working to create a base framework for our organization for web and client-side applications. The framework interfaces with several of our systems and provides the business and data layer...
4
by: pdlemper | last post by:
Have carefully installed Python 2.5.1 under XP in dir E:\python25 . ran set path = %path% ; E:\python25 Python interactive mode works fine for simple arithmetic . Then tried >> import math Get...
3
by: iu2 | last post by:
Hi, I'm trying to write data to both a file and the console, so I did: class File_and_console(file): def write(self, s): file.write(self, s) print s, hello
36
by: Roedy Green | last post by:
The only browser I have encountered that supports <colgroup><col class="behold"></colgroup> to apply a CSS style to a whole column, is Microsoft Internet Explorer. I have been told it SHOULD NOT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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,...
0
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...
0
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...
0
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
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,...

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.