How to get short date for Get short date for System Nullable datetime (datetime ?)
www.un.org/Depts/DGACM/index_french.htm www.un.org/spanish/ga/president
页: 1 ToShortDateString available.
How to get short date for Get short date for System Nullable datetime (datetime ?)
www.un.org/Depts/DGACM/index_french.htm www.un.org/spanish/ga/president
页: 1 ToShortDateString available.
页: 1 数值代码>首先(从中删除)。
var shortString = yourDate.Value.ToShortDateString();
但也检查了<代码>your 日期:有价值:
if (yourDate.HasValue) {
var shortString = yourDate.Value.ToShortDateString();
}
string.Format("{0:d}”, dt);
working:
DateTime? dt = (DateTime?)DateTime.Now;
string dateToday = string.Format("{0:d}", dt);
If the DateTime?
is null
this returns an empty string.
请注意:与
这一职能绝对可在<代码>Datetime类别之内。 请参阅“MSDN”类文件:。
由于<代码>Nullable,在<代码>上通用。 日期:代码>。 数值代码><代码> > 代码> 名称:>
DateTime? date;
String shortDateString;
shortDateString = date.Value.ToShortDateString();
仅知道,如果你在<条码>时尝试这样做的话,就会放弃一个例外。
如希望保证有显示价值,可与<代码>一起使用
yourDate.GetValueOrDefault().ToShortDateString();
如果价值确实无效,则将显示01/01/0001。
Check if it has value, then get required date
if (nullDate.HasValue)
{
nullDate.Value.ToShortDateString();
}
提 出
if (nullDate.HasValue)
{
nullDate.Value.ToShortDateString();
}
如果你使用......cshtml,你可以使用
<td>@(item.InvoiceDate==null?"":DateTime.Parse(item.YourDate.ToString()).ToShortDateString())</td>
或者如果你试图在C#中找到行动或方法上的短日期,那么
yourDate.GetValueOrDefault().ToShortDateString();
以上是Steve。
我也赞同我的项目中所采用的做法。 罚款。 谢谢。
A more concise way to do the same thing would be
var shortString = yourDate?.Date;
which would return a null if it is a null and the short date if it is not null.
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
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. ...
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 ...
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 ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
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, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
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. ...