473,606 Members | 2,200 Online
Bytes | Software Development & Data Engineering Community
+ 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 = DataControlRowT ype.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 1749
On 2007-11-13 14:42:38 -0800, TisMe <si**********@g ooglemail.comsa id:
I have the following if statement:

if ((e.Row.RowType = DataControlRowT ype.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**********@g ooglemail.comwr ote:
>Hi All,

I have the following if statement:

if ((e.Row.RowType = DataControlRowT ype.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**********@g ooglemail.comwr ote in message
news:11******** **************@ v3g2000hsg.goog legroups.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 = DataControlRowT ype.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 == DataControlRowT ype.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
3850
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 "base" syntax. Seems like we could put the @ symbol to good use in these situations. Examples: print @(separator = None) x, y, z @x,y:x*x+y*y -- anonymous function
68
4325
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 don't like the brackets.
2
1936
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 runtime by calling some function or 'meta-constructor' which returns a customized class and sets a class attribute according a given parameter. Ideally, I'd be able to do something like:
7
248454
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 particular surname in a particular town. I can select the records fine with this syntax (testing in Oracle SQL* Plus) SELECT NAMEINFO.LASTNAME, NAMEINFO.FIRSTNAME, NAMEINFO.MIDDLENAME, NAMEINFO.GENDER, ADDRESSINFO.REGION FROM NAMEINFO, ADDRESSINFO...
14
2497
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 in a table (I'll call it NewInfo) that has similar fields. NewInfo may contain multiple records for each Store/Item, but I will just use the latest status. I'm not sure how to update StoreItemStatus using each record of NewInfo. Any advice is...
13
2549
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(){}, my_meth2: function(){} }); to define new methods on the MyObj prototype object. Object.extend
0
2692
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 works for files larger than 8000 Bytes. If a file is less than 1000 Bytes I get the following message: Error message: --invalid input syntax for type oid: "\074\077......";
8
1785
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 with statement is indeed bad. My initial thoughts on with were based on: http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/ I built some examples to investigate - and later try to "eliminate"
14
5809
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
8015
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8439
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8305
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5966
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5465
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3930
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2448
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 we have to send another system
1
1553
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.