[英]Check the Picture box value is null or not
我使用Visual Studio IDE开发了一个可视化的C#窗体应用程序。
我的问题是如何检查用户是否选择了图像。
我粗略地检查图像像一个字符串,整数对象,但它不起作用
if(myPictureBox.Image == NULL){
//The Image is Null
}
你可以这样检查一下
bool isNullOrEmpty = myPictureBox == null || myPictureBox.Image == null;
或者您可以创建自己的扩展方法
public static bool IsNullOrEmpty(this PictureBox pb)
{
return pb == null || pb.Image == null;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.