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

后端 未结 7 449
粉色の甜心
粉色の甜心 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:35

    You are using wrong parameter type. You can use Equals as an instance level method or a type level (static) method:

    string.Equals(str1, str2, StringComparison comp);
    
    str1.Equals(str2, StringComparison comp);
    

    So, in both, you need StringComparison, not StringComparer. And your one:

    totalValue += Session["IsChauffeurUsed"].ToString().Equals("Yes", StringComparison.CurrentCultureIgnoreCase) ? 80 : 0;
    

提交回复
热议问题