草庐IT

3gp-how-convert

全部标签

c# - Convert.ToDateTime 在下午日期/时间值上导致 FormatException

我们有一个应用程序解析以下格式的日期/时间值:2009-10-1009:19:12.1242009-10-1012:13:14.8522009-10-1013:00:002009-10-1015:23:32.022一个特定的服务器突然(今天)在13:00:00或更晚的任何时间开始解析失败。这个特定的客户端有五台服务器,只有一台有问题。我们有几十个其他客户,总共有数百台服务器没有问题。System.FormatException:StringwasnotrecognizedasavalidDateTime.atSystem.DateTimeParse.Parse(Strings,Date

c# - ASP.NET MVC : How to obtain assembly information from HtmlHelper instance?

我在一个独立于我的MVC应用程序程序集的程序集中有一个HtmlHelper扩展方法。在扩展方法中,我想获取MVC应用程序程序集的版本号。这可能吗?调用程序集是razorView动态程序集,因此没有帮助。HtmlHelper中是否嵌套了某个对象可以为我提供MVC应用程序程序集的版本号?我一直在探索HtmlHelperclassdocumentation但到目前为止还没有找到解决我的问题的方法。谢谢! 最佳答案 这是出了名的邪恶-因为不幸的是,没有一种特定的可靠方法可以做到这一点。但是,由于它是一个MVC应用程序,它很可能有一个Glob

c# - ASP.NET Core 2.0 预览版 1 : How to set up Cookie Authentication with custom login path

在ASP.NETCore2.0中,.UseAuthentication()中间件有一个重大更改,不再允许oldsyntaxmentionedhere去工作。新版本似乎在addAuthentication中处理配置,但我无法在任何地方找到任何关于如何更改指定自定义登录和注销url的旧代码的详细信息。services.AddAuthentication(o=>{//WherecanIspecifythis?????varopt=newCookieAuthenticationOptions(){LoginPath="/api/login",LogoutPath="/api/logout",}

C# XML Comments : How many <see . ../> XML 注释中的引用有用吗?

在我们公司,我们写了过多的Xml注释。典型的方法必须像这样记录://////Determineswhetherthiscontainsaspecific.//////Thetolocateinthis.//////Returnsifisfoundinthis;otherwise,.///boolContains(IScheduleschedule);//////Removesandsthefirstoccurrenceofaspecific///fromthis.//////Thetoremovefromthis.///Isthrownwhentheparameterschedulei

c# - Entity Framework 代码优先 : How to ignore classes

这类似于问题here和here,但这些都是旧的,没有好的答案。假设我有以下类(class):classHairCutStyle{publicintID{get;set;}publicstringName{get;set;}}classCustomerHairCutPreference{publicintID{get;set;}publicCustomerCustomer{get;set;}publicHairCutStyleHairCutStyle{get;set;}}假设我的HairCutStyle数据存储在另一个数据库的一个表中(我从PaulMitchell自己那里得到它)。我想将

c# - 如何从 C# 中的异步任务 <bool> 函数获取 bool 结果 - 错误 : Cannot implicitly convert type `void' to `bool'

我已经创建了任务函数来验证我的json文件。一切正常,直到我没有使用结果。当我试图从asynctaskfunction获得结果时它显示错误为Cannotimplicitlyconvert'void'tobool.我的异步函数如下:privateasyncTaskMyValidationFunction(stringjson){boolisValid=true;.......DOINGMYVALIDATIONSTUFF.....returnisValid;}从另一个函数调用这个函数如下:publicboolGetJsonAndValidate(){boolisValid=true;str

c# - 如何关闭 resharper 中的 "Convert Extension Method to Plain Static"自动重构?

在使用Resharper时,由于某些原因,当我调用扩展方法时,它会自动将其转换为静态方法调用。这就是所谓的ConvertExtensionMethodtoPlainStatic重构。foo.Bar()成为MyStaticExtensions.Bar(foo);具有讽刺意味的是,它随后将此标记为代码异味。我该如何关闭它? 最佳答案 Resharper的IntelliSense中嵌入了此功能。我经常使用Linq-to-sql扩展,所以我禁用了这个功能:Resharper-选项-IntelliSense-启用RadiobuttonVisu

c# - 极端内存条件测试 : How to saturate RAM?

我想写一小段程序来启动线程,以线性方式消耗可用的RAM内存,直到达到一定水平,然后停止(理想情况下,暂停直到“足够”的内存被释放,然后继续创建线程,依此类推。)我尝试了以下操作,但是list.Add(newbyte[])需要连续的RAM空间并抛出一个OutOfMemoryException,这不是我想要的模拟。编辑:我有一个多线程的内存消耗型应用程序,它占用了一大堆RAMGB。我想要的只是在“实验室条件”中隔离/重现这种情况以解决它,即编写自适应内存监控/线程限制器草案。我正在使用x64操作系统和x64平台。说清楚:我想看到的结果是任务管理器内存监视器由于程序而直线上升。staticv

c# - 接口(interface)继承多个接口(interface) : how is this handled by a C# compiler?

最近我发现C#允许Aninterfacecaninheritfromoneormorebaseinterfaces.例如,Caliburn.Micro中的IScreen在http://caliburnmicro.codeplex.com/SourceControl/latest#src/Caliburn.Micro/IScreen.cs中执行此操作namespaceCaliburn.Micro{publicinterfaceIScreen:IHaveDisplayName,IActivate,IDeactivate,IGuardClose,INotifyPropertyChangedE

c# - 如何修复 'compiler error - cannot convert from method group to System.Delegate' ?

publicMainWindow(){CommandManager.AddExecutedHandler(this,ExecuteHandler);}voidExecuteHandler(objectsender,ExecutedRoutedEventArgse){}错误1​​参数2:无法从“方法组”转换为“System.Delegate” 最佳答案 我猜有多个具有不同签名的ExecuteHandler。只需将您的处理程序转换为您想要的版本:CommandManager.AddExecuteHandler(this,(Action)