草庐IT

TYPE_CLASS_DATETIME

全部标签

c# - 将 Xamarin Forms 中的 DateTime 格式化为设备格式字符串

在运行PCLXamarin.Forms项目并且我的部署目标包括iOS、Android和Windows时,如何将DateTime对象格式化为设备默认日期时间格式的字符串。根据此thread,DateTime.ToShortString()无法按照MSDN要求工作还有这个bug.是否有任何基于表单的解决方案,或者我是否需要从特定于平台的项目中获取它?对于Android,我可以使用DI从native项目执行以下操作:Stringformat=Settings.System.GetString(this.context.ContentResolver,Settings.System.DateF

c# - "new"inside concrete type projection 只被调用一次

我有简单的Linq2Sql查询:varresult=fromtinMyContext.MyItemsselectnewMyViewModelClass(){FirstProperty=t,SecondProperty=newSomeLinq2SqlEntity()}问题是newSomeLinq2SqlEntity()似乎只对该序列执行一次,因此查询结果中MyViewModelClass的所有实例共享链接到一个对象。更新:这是我快速检查它的方法:result[0].SecondProperty.MyField=10;使用调试器,我可以检查MyField在所有情况下都设置为10。当我用fo

c# - Content-Type 字符集是否未从 HttpResponseMessage 公开?

我正在将一些代码从使用HttpWebRequest转换为HttpClient。我遇到的一个问题是从内容类型响应header获取字符集。使用HttpWebRequest时,字符集在HttpWebResponse.CharacterSet属性中公开,如下所示using(WebResponseresponse=awaitthis.webRequest.GetResponseAsync()){stringcharacterSet=((HttpWebResponse)response).CharacterSet;您还可以从WebResponse.ContentType属性或从HttpWebRes

c# - "Unable to cast object of type ' System.Net.Http.Formatting.JsonContractResolver ' to type ' Newtonsoft.Json.Serialization.DefaultContractResolver '."

我们有一个最近被转移到新服务器的WEBAPI项目。在对项目的有效负载进行一些添加后,我正在运行我的项目,但它突然抛出以下错误:Unabletocastobjectoftype'System.Net.Http.Formatting.JsonContractResolver'totype'Newtonsoft.Json.Serialization.DefaultContractResolver'.有问题的代码行在global.asax中:protectedvoidApplication_Start(){GlobalConfiguration.Configure(WebApiConfig.R

c# - FileLoadException 在 InitializeComponent 或 x :Class=

我在InitializeComponent方法中遇到文件加载器异常(第一次机会),或者调试器在多个WPF的xaml-root的x:Class属性处中断用户控制。尽管异常会大大降低导航速度,但一切正常。这是异常信息:Couldnotloadfileorassembly'Company.Solution.UserInterface,Version=0.1.5568.25577,Culture=neutral,PublicKeyToken=45069ab0c15881ce'oroneofitsdependencies.Thelocatedassembly'smanifestdefinitio

c# - 为什么具有 "where T : class"约束的 Generic<T> 方法接受接口(interface)

我有这个interface:publicinterfaceITestInterface{intTestInt{get;set;}}和这个通用方法(带有T:class约束):publicvoidTest()whereT:class{//DoSomething}这个电话:Test();一切都编译并运行,同时interface不是class(或者是吗?)。为什么会这样?我第一次看到这个是在我的WCF代理类上:publicpartialclassTestServiceClient:System.ServiceModel.ClientBase,TestNamespace.ITestService

c# - 代码契约(Contract) : Why are some invariants not considered outside the class?

考虑这个不可变类型:publicclassSettings{publicstringPath{get;privateset;}[ContractInvariantMethod]privatevoidObjectInvariants(){Contract.Invariant(Path!=null);}publicSettings(stringpath){Contract.Requires(path!=null);Path=path;}}这里需要注意两点:有一个保证Path属性永远不会为null的契约不变量构造函数检查path参数值以遵守先前的契约不变量此时,Setting实例永远不能有n

c# - DateTime.ParseExact 具有 7 位数字/一位或两位数字的月份

到现在为止,我认为我会理解DateTime.ParseExact的工作原理,但这令人困惑。为什么下一行返回false?DateTime.TryParseExact("2013122","yyyyMdd",CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None,outlastUpdate)月份也可以有两位数。我认为它应该能够理解它意味着2013年1月22日。为什么我走错了路?我是否遗漏了什么或者是否有简单的解决方法?与此同时,我正在使用这个不是很优雅但有效的解决方法:publicstaticDateTim

c# - 使用 Interlocked 的线程安全 DateTime 更新。*

我可以使用Interlocked.*同步方法来更新DateTime变量吗?我希望在内存中保留最后一次触摸时间戳。多个http线程将更新最后一次触摸DateTime变量。我很欣赏DateTime变量是被替换而不是更新的值类型。我能想到的最好的方法是将时间戳记作为一个long中的总滴答数classx{long_lastHit;voidTouch(){Interlocked.Exchange(ref_lastHit,DateTime.Now.Ticks);}} 最佳答案 选项1:使用带有Interlocked和DateTime.ToBin

c# - Visual Studio express : free class diagram tool

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭8年前。Improvethisquestion我正在使用c#express并希望使用免费工具来设计我的类图。您有什么推荐的免费工具?