C#WPF无法正常工作.... [英] C# WPF something not working well ....

查看:85
本文介绍了C#WPF无法正常工作....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

this is my code

if (setcdate.Content == "00/00/0000")
       {
       }
       else
       {
}



这是我的错误



and this is my error

Warning 1   Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'   C:\Users\Kyle\documents\visual studio 2010\Projects\DaysUntill\DaysUntill\MainWindow.xaml.cs    104 17  DaysUntill



setcdate是标签



and setcdate is a label

can some plz help me?

推荐答案

您没有显示足够的代码,但简单的事实是:内容不是字符串(很可能是System.Object) ,那么如何比较这两个对象?您可以使用string compare = setcdata.Content as string.如果不是字符串,它将返回null并给出正确的比较:null == "00/00/0000"将给您false.

但是,我非常确定这种比较的整体思路是错误的.为什么要这样做?

—SA
You don''t show enough code, but the simple fact is: Content is not string (most likely, System.Object), so how can you compare the two objects? You can use string compare = setcdata.Content as string. In case this is not string it will return null which give correct comparison: null == "00/00/0000" will give you false.

However, I''m pretty much sure the whole idea of this comparison is wrong. Why doing it?

—SA


这篇关于C#WPF无法正常工作....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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