English 中文(简体)
日期: 现在发言
原标题:DateTime.Now within a statement

在以下的<代码>中,该编码始终适用。

DateTime d = DateTime.Now;
bool thisIsAlwaysTrue = d == d;

但是,时间确实是这样。 现在的工作方式就是: 真的保证是真实的? 或者,提及现在财产之间的锁定变化吗?

bool isThisAlwaysTrue = DateTime.Now == DateTime.Now;
最佳回答

锁定可以在两个接连电话到日期之间改变。 现在:

问题回答

日期。 如今,财产变幻莫测,也就是说,这无疑会改变用途。 但是,你赋予它的变量并非不稳定。

因此,这应当永远产生以下结果:

DateTime d = DateTime.Now;
bool result = d == d;

它按时间分配退还的价值。 现在是变数,而不是财产本身。 因此,该法典将永远平等。

但是,这并不总是真正的结果:

bool result = DateTime.Now == DateTime.Now;

我必须建议你努力这样做。 该法典在单元中只占第二部分:

using System;

class Program {
  static void Main(string[] args) {
    while (DateTime.UtcNow == DateTime.UtcNow) ;
    Console.WriteLine("oops");
    Console.ReadLine();
  }
}

我相信,它将会恢复。

时间是不可改变的,因此一旦分配,时间就永远不会改变。 您对日期的呼吁。 现在就没有“联系”——它只是分配了什么<>? 日期: 现在需要的是变数(d)——它不会给出某种参考。

因此,如果出现这样的拖延:

DateTime d = DateTime.Now; // Let s assume it s 9:05:10
Thread.Sleep(100);
Console.WriteLine(d); // will still be 9:05:10, even though it s much later now




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签