什么是“多长时间?”数据类型? [英] What is 'long?' data type?

查看:103
本文介绍了什么是“多长时间?”数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在其他开发人员编写一些代码,我不知道是什么表示:

 保护字符串AccountToLogin(?长ID)
{
串LOGINNAME =;
如果(id.HasValue)
{

{....


解决方案

相同的Int64



long数据类型



意味着它是可空




一个可空类型可以表示其
标的值类型值
正常范围,加上
附加空值




空类型



可空例如:

 诠释? NUM = NULL; 
如果(num.HasValue ==真)
{
的System.Console.WriteLine(数=+ num.Value);
}
,否则
{
的System.Console.WriteLine(NUM =空);
}

这允许你居然查了值,而不是试图分配的东西任意值进行检查,看看是否有失败。



其实,我写了一篇博客文章中针对此<一个HREF =http://robertgreiner.com/2010/04/write-better-code-using-nullable-with-csharp/>这里。


I am going over some code written by another developer and am not sure what long? means:

protected string AccountToLogin(long? id)
{
   string loginName = "";
   if (id.HasValue)
   {
      try
      {....

解决方案

long is the same as Int64

long data type

The ? means it is nullable

A nullable type can represent the normal range of values for its underlying value type, plus an additional null value

Nullable Types

Nullable example:

int? num = null;
if (num.HasValue == true)
{
    System.Console.WriteLine("num = " + num.Value);
}
else
{
    System.Console.WriteLine("num = Null");
}

This allows you to actually check for a null value instead of trying to assign an arbitrary value to something to check to see if something failed.

I actually wrote a blog post about this here.

这篇关于什么是“多长时间?”数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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