Compiler error
-
Hi All, Im trying to run this code:
foreach (DataRow dr in ds.Tables["table1"].Rows) { if (dr[1].ToString() == "f") { dr[1].ToString() = "finish"; } else { dr[1].ToString() = "not finish"; } }
But im getting the error: The left-hand side of an assignment must be a variable, property or indexer Could'nt find anything on google that solves this. Anyone a idea? Thanx -
Hi All, Im trying to run this code:
foreach (DataRow dr in ds.Tables["table1"].Rows) { if (dr[1].ToString() == "f") { dr[1].ToString() = "finish"; } else { dr[1].ToString() = "not finish"; } }
But im getting the error: The left-hand side of an assignment must be a variable, property or indexer Could'nt find anything on google that solves this. Anyone a idea? ThanxYou are assigning a value to a result of a function.
#region signature my articles #endregion
-
Hi All, Im trying to run this code:
foreach (DataRow dr in ds.Tables["table1"].Rows) { if (dr[1].ToString() == "f") { dr[1].ToString() = "finish"; } else { dr[1].ToString() = "not finish"; } }
But im getting the error: The left-hand side of an assignment must be a variable, property or indexer Could'nt find anything on google that solves this. Anyone a idea? ThanxIt is generally better to convert from
object
to a concrete type by casting, if you know what type an expression is, than to use a conversion function. I would write this asforeach (DataRow dr in ds.Tables["table1"].Rows)
{
if ( (string)dr[1] == "f" )
{
dr[1] = "finish";
}
else
{
dr[1] = "not finish";
}
}DoEvents: Generating unexpected recursion since 1991
-
Hi All, Im trying to run this code:
foreach (DataRow dr in ds.Tables["table1"].Rows) { if (dr[1].ToString() == "f") { dr[1].ToString() = "finish"; } else { dr[1].ToString() = "not finish"; } }
But im getting the error: The left-hand side of an assignment must be a variable, property or indexer Could'nt find anything on google that solves this. Anyone a idea? ThanxRemove the toString() from dr[1].ToString() and dr[1].ToString()... Everything will work fine
Regards, Jaiprakash M Bankolli jaiprakash.bankolli@gmail.com My Blog Suggestions for me
-
Hi All, Im trying to run this code:
foreach (DataRow dr in ds.Tables["table1"].Rows) { if (dr[1].ToString() == "f") { dr[1].ToString() = "finish"; } else { dr[1].ToString() = "not finish"; } }
But im getting the error: The left-hand side of an assignment must be a variable, property or indexer Could'nt find anything on google that solves this. Anyone a idea? ThanxHi Justim, this is not a compiler error at all; at best it is a compiler-generated error message, due to a Justim error. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.