This is a discussion on ASP.NET e.CommandArgument is a reference type? within the Programming forums, part of the Web Designing & Development category; I found this in a co-workers code & resharper flagged it as a logical error. Could somebody please help me ...
I found this in a co-workers code & resharper flagged it as a logical error. Could somebody please help me explain this? it doesn't cause a runtime error, but I know that its a bad practice. I'm just not good at explaining why.
protected void myDataList_UpdateCommand(object sender, DataListCommandEventArgs e)
{
if (e.CommandArgument == "Group")
....
}
On the == sign, resharper puts "Possible unintended reference comparison; to get a value comaprison , cast the left hand side of the expression to type 'string'
All examples on the microsoft site have it cast to a string, or using the .ToString() method. I can't find any discussion of it being a value or reference type out there though.
Bookmarks