草庐IT

what_am_i

全部标签

c# - 错误 - SqlDateTime 溢出。必须在 1/1/1753 12 :00:00 AM and 12/31/9999 11:59:59 PM 之间

我有一个为2008年编写的应用程序。我们正在对实体使用linq。我们现在不得不将数据库切换到2005。我在linqSELECT查询中收到以下错误:Error-SqlDateTimeoverflow.Mustbebetween1/1/175312:00:00AMand12/31/999911:59:59PM.违规行是:DateOfBirth=((s.Date_Of_Birth==null)||(s.Date_Of_BirthDateOfBirth是DateTime类型,是我们自己的业务对象(不是实体)中的一个属性。有人知道我如何修改这一行来运行这个查询吗? 最

c# - 如何将包含 AM/PM 的字符串转换为 DateTime?

我如何将这样的字符串:“2/22/20159:54:02AM”解析为DateTime实例?我目前正在使用DateTime.ParseExact方法但没有AM/PM即:DateTime.ParseExact("2/22/20159:54:02","M/dd/yyyyHH:mm:ss")我也希望能够解析AM/PM标志。 最佳答案 您应该将小时格式(H)更改为小写,如下所示:DateTime.ParseExact("2/22/20159:54:02AM","M/d/yyyyh:mm:sstt",CultureInfo.InvariantC

c# - Windows 服务计划每天在 6 :00 AM 运行一次

我已经创建了一个Windows服务,我希望该服务计划在每天早上6:00运行。下面是我写的代码:-publicService1(){InitializeComponent();}protectedoverridevoidOnStart(string[]args){try{ExtractDataFromSharePoint();}catch(Exceptionex){//DisplaysandLogsMessage_loggerDetails.LogMessage=ex.ToString();_writeLog.LogDetails(_loggerDetails.LogLevel_Erro

c# - OOPS 概念 : What is the difference in passing object reference to interface and creating class object in C#?

我有一个类CustomerNew和一个接口(interface)ICustomer:publicclassCustomerNew:ICustomer{publicvoidA(){MessageBox.Show("Classmethod");}voidICustomer.A(){MessageBox.Show("Interfacemethod");}publicvoidB(){MessageBox.Show("ClassMethod");}}publicinterfaceICustomer{voidA();}我对这两行代码很困惑。ICustomerobjnew=newCustomerNe

c# - CA1819 : Properties shouldn't return arrays - What is the right alternative?

我以前遇到过这个FxCop规则,但对如何解决违规问题并不满意(thread1、thread2)。我现在有另一个案例,我需要纠正违反CA1819的行为亲切。具体来说,我有一个算法库,它使用如下所示的公共(public)“输入对象”对曲线(x,y)执行一些分析计算:publicclassInputObject{publicdouble[]X{get;set;}publicdouble[]Y{get;set;}//+lotsofotherthingswell}此对象的X和Y属性在库中的数百个位置使用,通常使用索引。输入对象永远不会被算法改变,但实际上如果是这样也无关紧要。另外,.Length

c# - 使用 DateTime.ToString ("tt"时,Windows 10 中的时间输出(AM/PM)发生了变化)

我最近升级到Windows10-现在我发现在使用“tt”格式说明符时日期的输出发生了一些意想不到的变化。下面是一些演示问题的代码:usingSystem.IO;usingSystem;usingSystem.Globalization;usingSystem.Threading.Tasks;classProgram{staticvoidMain(){varcultures=newstring[]{null,"en-NZ","en-US","en-AU","en-GB"};foreach(varcultureincultures){if(culture!=null){varc=Cultu

c# - Hangfire 禁用并发执行 : What happens when the timeout expires?

根据Hangfire0.8.2announcementpost,Hangfire有一个DisableConcurrentExecution过滤器,当应用于一个方法时,它会阻止该方法的多个实例同时执行。DisableConcurrentExecution过滤器采用timeoutInSecondsint参数。来自链接文章中的示例:[DisableConcurrentExecution(timeoutInSeconds:10*60)]publicvoidSomeMethod(){//Operationsperformedinsideadistributedlock}我的问题是:给定一个正在等

c# - MVC : what code gets called when you click the "submit" button?

MVC新手问题;我通过玩耍而不是阅读手册来学习...:)我在创建“编辑”View时发现自动生成的View包含一个“提交”按钮:但是在幕后调用什么代码来执行此保存操作?具体来说,这个View的基础模型在我想要调用的代码中有自己的奇特保存逻辑。我如何让View调用我的代码,而不是在幕后无形地调用任何标准代码? 最佳答案 定义发生什么的不是按钮,而是表单本身。提交类型的按钮(每个表单一个)仅触发表单提交,由表单本身处理。一个表单有一个Action——例如:操作是一个URL,浏览器会收集表单中所有字段的值()并将它们发布到指定的url。在A

c# - 计时器、事件和垃圾收集 : am I missing something?

考虑以下代码:classTestTimerGC:Form{publicTestTimerGC(){ButtonbtnGC=newButton();btnGC.Text="GC";btnGC.Click+=(sender,e)=>GC.Collect();this.Controls.Add(btnGC);System.Windows.Forms.Timertmr=newSystem.Windows.Forms.Timer();tmr.Interval=1000;tmr.Tick+=(sender,e)=>this.Text=DateTime.Now.ToString();tmr.Star

C# - 基本问题 : What is '?' ?

这个问题在这里已经有了答案:Whatdoes"DateTime?"meaninC#?(7个答案)关闭9年前。我想知道?在C#中是什么意思?我看到类似这样的内容:DateTime?或int?。我想这是C#4.0特有的?我无法在谷歌中找到它,因为我不知道这个东西的名字。问题是我正在使用DateTime并且我有很多转换错误(从DateTime到DateTime?)。谢谢