成员'object.Equals(object,object)'不能通过实例引用进行访问;用类型名称来代替它 [英] Member 'object.Equals(object, object)' cannot be accessed with an instance reference; qualify it with a type name instead

查看:122
本文介绍了成员'object.Equals(object,object)'不能通过实例引用进行访问;用类型名称来代替它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在C#中使用以下代码时...

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

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

// This line causes the error
totalValue += Session["IsChauffeurUsed"].ToString().Equals("Yes", StringComparer.CurrentCultureIgnoreCase) ? 80 : 0;

...我收到此错误:

... I received this error :

成员'object.Equals(object,object)'不能通过实例引用进行访问;而是使用类型名称来限定它.

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

该错误表示什么?

推荐答案

int totalValue = 0;
int total = 0;
totalValue = int.Parse("2".ToString()) * int.Parse("2".ToString());
string s = "Yes";
totalValue += s.Equals("Yes",StringComparison.CurrentCultureIgnoreCase) ? 80 : 0;

这篇关于成员'object.Equals(object,object)'不能通过实例引用进行访问;用类型名称来代替它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆