发生了什么事.ToShortDateString在.NET可移植类库 [英] What happened to .ToShortDateString in .NET Portable Class Library

查看:223
本文介绍了发生了什么事.ToShortDateString在.NET可移植类库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么没有 .ToShortDateString 在.NET移植类库。我有2个项目(Silverlight和普通.NET类库)使用相同的代码,并且代码需要调用 .ToShortDateString()日期时间对象。为了重复使用相同的代码,而不是在两个地方复制它的,我创建了一个可移植的类库,因此它可以由双方Silverlight和.NET类库进口。不幸的是,它似乎像 .ToShortDateString不()使用类库时可用。我可以接受在便携式类库方法的字符串参数,并传递来自Silverlight和类库项目 .ToShortDateString()价值,但我想知道为什么这种方法ISN ŧ本土的便携库。它是一个文化问题?

I am wondering why there is no .ToShortDateString in the .NET Portable Class Library. I have 2 projects (Silverlight, and regular .NET Class Library) that use the same code, and the code involves calling .ToShortDateString() on a DateTime object. In order to reuse the same code instead of copying it in 2 places, I created a portable class library so it can be imported by both Silverlight and .NET Class Library. Unfortunately, it doesn't seem like .ToShortDateString() is available when using the class library. I can accept a string parameter in the portable class library method and pass the .ToShortDateString() value from both silverlight and class library projects, but I am wondering why this method isn't native for the portable library. Is it a culture issue?

推荐答案

虽然大多数方法/属于在系统命名空间中定义的类型属性在PCLS可用,也有一些例外,并且ToShortDateString就是其中之一。下面是便携式的DateTime成员列表。我不知道是什么的一些字符串转换方法排除背后的原因,但我想这是因为冗余。正如cadrell0指出的那样,你可以随时使用的ToString带参数达到同样

While most of methods/properties that belong to types defined in System namespace are available in PCLs, there are some exceptions, and ToShortDateString is one of them. Below is the list of portable DateTime members. I don't know what was the reason behind the exclusion of some string conversion methods, but I guess this is due to redundancy. As cadrell0 pointed out, you can always achieve the same by using ToString with a parameter.

T:System.DateTime
M:System.DateTime.ToString(System.String)
M:System.DateTime.op_GreaterThan(System.DateTime,System.DateTime)
M:System.DateTime.ParseExact(System.String,System.String[],System.IFormatProvider,System.Globalization.DateTimeStyles)
M:System.DateTime.get_Month
M:System.DateTime.FromFileTimeUtc(System.Int64)
M:System.DateTime.get_Date
M:System.DateTime.get_TimeOfDay
M:System.DateTime.get_Kind
M:System.DateTime.ToUniversalTime
M:System.DateTime.get_Year
M:System.DateTime.op_Subtraction(System.DateTime,System.TimeSpan)
M:System.DateTime.get_Second
M:System.DateTime.get_DayOfWeek
M:System.DateTime.TryParse(System.String,System.IFormatProvider,System.Globalization.DateTimeStyles,System.DateTime@)
M:System.DateTime.#ctor(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)
M:System.DateTime.get_Day
P:System.DateTime.Date
M:System.DateTime.op_Addition(System.DateTime,System.TimeSpan)
M:System.DateTime.IsDaylightSavingTime
M:System.DateTime.get_DayOfYear
M:System.DateTime.ToFileTime
M:System.DateTime.Subtract(System.DateTime)
M:System.DateTime.IsLeapYear(System.Int32)
M:System.DateTime.#ctor(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.DateTimeKind)
M:System.DateTime.ParseExact(System.String,System.String,System.IFormatProvider,System.Globalization.DateTimeStyles)
P:System.DateTime.Day
M:System.DateTime.get_Hour
M:System.DateTime.Equals(System.DateTime)
M:System.DateTime.get_UtcNow
M:System.DateTime.get_Today
M:System.DateTime.TryParse(System.String,System.DateTime@)
P:System.DateTime.Kind
M:System.DateTime.System#IComparable#CompareTo(System.Object)
P:System.DateTime.UtcNow
P:System.DateTime.Hour
P:System.DateTime.Millisecond
M:System.DateTime.Parse(System.String)
F:System.DateTime.MinValue
M:System.DateTime.op_GreaterThanOrEqual(System.DateTime,System.DateTime)
M:System.DateTime.#ctor(System.Int64,System.DateTimeKind)
M:System.DateTime.GetHashCode
P:System.DateTime.Year
M:System.DateTime.Add(System.TimeSpan)
M:System.DateTime.Equals(System.DateTime,System.DateTime)
M:System.DateTime.ToString(System.IFormatProvider)
M:System.DateTime.get_Now
P:System.DateTime.Month
M:System.DateTime.DaysInMonth(System.Int32,System.Int32)
M:System.DateTime.AddMinutes(System.Double)
M:System.DateTime.get_Minute
M:System.DateTime.#ctor(System.Int64)
M:System.DateTime.op_LessThanOrEqual(System.DateTime,System.DateTime)
M:System.DateTime.ToString(System.String,System.IFormatProvider)
P:System.DateTime.DayOfYear
M:System.DateTime.AddMilliseconds(System.Double)
P:System.DateTime.Second
P:System.DateTime.DayOfWeek
M:System.DateTime.op_Equality(System.DateTime,System.DateTime)
M:System.DateTime.#ctor(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)
M:System.DateTime.TryParseExact(System.String,System.String,System.IFormatProvider,System.Globalization.DateTimeStyles,System.DateTime@)
M:System.DateTime.ToFileTimeUtc
P:System.DateTime.Today
M:System.DateTime.op_LessThan(System.DateTime,System.DateTime)
M:System.DateTime.get_Millisecond
M:System.DateTime.op_Subtraction(System.DateTime,System.DateTime)
M:System.DateTime.#ctor(System.Int32,System.Int32,System.Int32)
M:System.DateTime.ParseExact(System.String,System.String,System.IFormatProvider)
M:System.DateTime.AddSeconds(System.Double)
M:System.DateTime.AddMonths(System.Int32)
M:System.DateTime.AddYears(System.Int32)
M:System.DateTime.Parse(System.String,System.IFormatProvider,System.Globalization.DateTimeStyles)
M:System.DateTime.get_Ticks
P:System.DateTime.Ticks
M:System.DateTime.TryParseExact(System.String,System.String[],System.IFormatProvider,System.Globalization.DateTimeStyles,System.DateTime@)
M:System.DateTime.ToLocalTime
M:System.DateTime.op_Inequality(System.DateTime,System.DateTime)
M:System.DateTime.SpecifyKind(System.DateTime,System.DateTimeKind)
M:System.DateTime.AddHours(System.Double)
P:System.DateTime.Minute
M:System.DateTime.Subtract(System.TimeSpan)
M:System.DateTime.#ctor(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.DateTimeKind)
F:System.DateTime.MaxValue
M:System.DateTime.ToString
M:System.DateTime.FromFileTime(System.Int64)
P:System.DateTime.TimeOfDay
M:System.DateTime.Compare(System.DateTime,System.DateTime)
M:System.DateTime.CompareTo(System.DateTime)
M:System.DateTime.Parse(System.String,System.IFormatProvider)
M:System.DateTime.AddDays(System.Double)
P:System.DateTime.Now
M:System.DateTime.Equals(System.Object)
M:System.DateTime.AddTicks(System.Int64)

这篇关于发生了什么事.ToShortDateString在.NET可移植类库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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