的含义是什么?操作员? [英] What is the meaning of the ? operator?

查看:83
本文介绍了的含义是什么?操作员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
C#使用问题在类型后标记,例如:int? myVariable;这是做什么用的?

Possible Duplicate:
C# using the question mark after a type, for example: int? myVariable; what is this used for?

我看到?运算符在很多地方都使用过,并尝试使用Google和StackOverflow,但两个搜索引擎都将其从查询中排除,并且未返回任何好的答案.

I saw the ? operator used in many places and tried to Google and StackOverflow it but both search engine exclude it from the query and does not return any good answers.

该运算符的含义是什么?我通常会在类型声明后看到它,例如:

What is the meaning of this operator? I usually see it after the type declaration like:

int? x;
DateTime? t;

例如,以下两个int声明之间有什么区别:

What is the difference between the two following declaration of an int for example:

int? x;
// AND
int x;

推荐答案

此运算符不是运算符,而只是

This operator is not an operator, but merely the syntactic sugar for a Nullable type:

int? x;

Nullable<int> x;

这篇关于的含义是什么?操作员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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