Member 'object.Equals(object, object)' cannot be accessed with an instance reference; qualify it with a type name instead

后端 未结 7 450
粉色の甜心
粉色の甜心 2021-01-17 10:59

When I used the following code in C#...

int totalValue = 0;
int total = 0;
totalValue = int.Parse(Session[\"price\"].ToString()) * int.Parse(Session[\"day\"]         


        
7条回答
  •  走了就别回头了
    2021-01-17 11:55

    I know it's quite late and also may not apply to user's case directly, just adding this answer to help out those who face same issue but due to different reason.

    Equal() method of a string instance needs first argument as string type.

    So if by any chance first argument is not of string type and is of another type let's say int, you get the same error which can be misleading sometimes as it won't say first argument should be of type string directly.

提交回复
热议问题