473,480 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C# Convertee - Help with IF statement syntax

Hi All,

I have the following if statement:

if ((e.Row.RowType = DataControlRowType.DataRow) &&
(e.Row.Cells[1].Text.ToLower() = "jake"))
{
e.Row.Cells[1].Text += "ALERT!!!";
}

I am getting the following compilation error on the first line shown
above:
CS0131: The left-hand side of an assignment must be a variable,
property or indexer

Can anyone help? I've tried a single ampersand, which gives me the
same error.

Basically, I am trying to say:

if ((this evaluates to true) AND (this evaluates to true)) Then
DO THIS
end if

Any help/advice will be much appreciated.

Thank you.

Nov 13 '07 #1
5 1741
On 2007-11-13 14:42:38 -0800, TisMe <si**********@googlemail.comsaid:
I have the following if statement:

if ((e.Row.RowType = DataControlRowType.DataRow) &&
(e.Row.Cells[1].Text.ToLower() = "jake"))
{
e.Row.Cells[1].Text += "ALERT!!!";
}

I am getting the following compilation error on the first line shown
above:
CS0131: The left-hand side of an assignment must be a variable,
property or indexer
You must be coming from VB.

You need "==" instead of "=" in your comparisons. A single equals is
strictly an assignment in C# (and other languages). Unlike VB,
assignments are evaluated expressions as well and so are legal anywhere
any expression is, including inside an if() statement, so the language
needs some other way to tell the difference than just context. It does
this by not overloading the "=" in the way that VB does.

Pete

Nov 13 '07 #2

You have "=" in your if statements, should be "==".

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Tue, 13 Nov 2007 14:42:38 -0800, TisMe
<si**********@googlemail.comwrote:
>Hi All,

I have the following if statement:

if ((e.Row.RowType = DataControlRowType.DataRow) &&
(e.Row.Cells[1].Text.ToLower() = "jake"))
{
e.Row.Cells[1].Text += "ALERT!!!";
}

I am getting the following compilation error on the first line shown
above:
CS0131: The left-hand side of an assignment must be a variable,
property or indexer

Can anyone help? I've tried a single ampersand, which gives me the
same error.

Basically, I am trying to say:

if ((this evaluates to true) AND (this evaluates to true)) Then
DO THIS
end if

Any help/advice will be much appreciated.

Thank you.
Nov 13 '07 #3
TisMe wrote:
(e.Row.Cells[1].Text.ToLower() = "jake"))
You need another = here, it thinks you're trying to assign.
(e.Row.Cells[1].Text.ToLower() == "jake"))
Chris.
Nov 13 '07 #4
Yup - I am coming from VB!

Thanks for your replies!

Nov 14 '07 #5
Liz

"TisMe" <si**********@googlemail.comwrote in message
news:11**********************@v3g2000hsg.googlegro ups.com...
Yup - I am coming from VB!

Thanks for your replies!
you might find this useful:

http://labs.developerfusion.co.uk/co...to-csharp.aspx
it will take this:

If (e.Row.RowType = DataControlRowType.DataRow) AndAlso
(e.Row.Cells(1).Text.ToLower() = "jake") Then
e.Row.Cells(1).Text += "ALERT!!!"
End If

and convert it to this:
{
if ((e.Row.RowType == DataControlRowType.DataRow) &&
(e.Row.Cells(1).Text.ToLower() == "jake")) {
e.Row.Cells(1).Text += "ALERT!!!";
}
}
Nov 15 '07 #6

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

Similar topics

75
3808
by: David MacQuigg | last post by:
Seems like we need a simple way to extend Python syntax that doesn't break existing syntax or clash with any other syntax in Python, is easy to type, easy to read, and is clearly distinct from the...
68
4281
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
2
1922
by: zipher | last post by:
After searching through comp.lang.python and the web regarding metaclasses, I could not find an example for customing classes using metaclass parameters. I want to be able to create a class at...
7
248429
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
14
2484
by: bolidev | last post by:
I'm new to SQL and can't figure out how to update my table (StoreItemStatus) that contains the current status for items in each store (STORE_KEY, ITEM_KEY, STATUS,...). I get updated status info...
13
2516
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
0
2681
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
8
1761
by: Rasmus Kromann-Larsen | last post by:
The With Conundrum I'm currently writing a master thesis on (preparations for) static analysis of JavaScript, and after investigating the with statement, it only even more evident to me that the...
14
5797
by: paresh | last post by:
Is this the valid C statement. int a,b,c; c = 5; <<< a = b = c; Can anyone throw the light on this. -Paresh
0
7059
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,...
1
6758
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
7010
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
5362
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,...
1
4799
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...
0
4499
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...
0
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
203
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.