为什么会出现在私人变量定义一个问号? [英] Why is there a questionmark on the private variable definition?

查看:116
本文介绍了为什么会出现在私人变量定义一个问号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读有关MVVP模式的文章,如何用WPF实现它。在源代码中有多个行,我想不通其中的问号代表什么。

I am reading an article about the MVVP Pattern and how to implement it with WPF. In the source code there are multiple lines where I cannot figure out what the question marks in it stand for.

private DateTime? _value;



什么的指的是在定义?我试图找到它从VS的帮助,但失败了。

What does the ? mean in the definition? I tried to find it in the help from VS but failed.

推荐答案

这是一个空值。结构,默认情况下,不能为空的,他们必须有一个值,所以在C#2.0中,可空< T> 类型被引入到.NET Framework。

It's a nullable value. Structs, by default, cannot be nullable, they must have a value, so in C# 2.0, the Nullable<T> type was introduced to the .NET Framework.

C#实现可空< T> 用一块语法糖,其中后放置一个问号型键入名称,从而使以前的非可空类型,可为空。

C# implements the Nullable<T> type with a piece of syntactic sugar, which places a question mark after the type name, thus making the previously non-nullable type, nullable.

这篇关于为什么会出现在私人变量定义一个问号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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