草庐IT

as-operator

全部标签

c# - 尝试读取 xml 文件时的 ASP.Net, "An operation was attempted on a nonexistent network connection"

stringurl="http://www.example.com/feed.xml";varsettings=newXmlReaderSettings();settings.IgnoreComments=true;settings.IgnoreProcessingInstructions=true;settings.IgnoreWhitespace=true;settings.XmlResolver=null;settings.DtdProcessing=DtdProcessing.Parse;settings.CheckCharacters=false;varrequest=(Ht

c# - SQL 2008 : returning data rows as JSON?

我觉得这个问题就像是射粘土飞鸽..“拉……砰!”..被击落..但尽管如此,我相信还是值得一问。现在很多JS框架等都使用JSON,我知道这是有充分理由的。经典问题是“在哪里将数据转换为JSON”。我知道在管道中的某个时刻,您必须将数据转换为JSON,无论是在数据访问层(我正在查看JSON.NET)还是我相信.NET4.x都有方法输出/序列化为JSON。所以问题是:考虑将SQL函数输出为JSON真的是个坏主意吗?预选赛:我知道尝试像那样输出1000行不是一个好主意——事实上,无论哪种方式对于Web应用程序来说都不是一个好主意,除非你真的必须这样做。根据我的要求,我一次可能需要100行...

c# - "unexpected response code for operation : 1"是什么意思?

我从尝试在Azure表存储中插入记录的应用程序中收到“意外的操作响应代码:1”。基本上是将数据放在TableOperation中,并且已经按100行block对插入进行了批处理。在网络上真的找不到很多关于此Azure错误消息中特定“1”代码的信息。 最佳答案 当批处理操作失败时,表服务返回HTTP状态代码400,同时发送导致该批处理失败的实体的索引。"unexpectedresponsecodeforoperation:1"这意味着在批处理中的位置1处插入实体时出现错误。 关于c#-"u

C# 不同的转换方式——(T)obj vs obj as T

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicate:castingvsusingthe'as'keywordintheCLR我见过两种不同的C#转换方式。例如:MyObjfoo=(MyObj)bar;//thisiswhatIseemostofthetimesMyObjfoo=barasMyObj;//Idoseethissometimes那么,基本区别是什么?style1和style2转换的正确名称是什么?我如何决定何时使用什么?是否存在任何重大性能问题?关于这个主题,还有什么我应该知道的吗?非常感谢您对此的调查:)

c# - C# "as"关键字是否有比简单转换更多的内容?

我正在处理JoshSmith'sCommandSinkcode显然不了解C#中的“as”关键字。我不明白他为什么要写这行:IsValid=_fe!=null||_fce!=null;因为他只需要写:IsValid=depObj!=null;因为永远不会出现_fe为null而_fce不为null的情况,反之亦然,对吧?还是我遗漏了有关“as”如何转换变量的信息?classCommonElement{readonlyFrameworkElement_fe;readonlyFrameworkContentElement_fce;publicreadonlyboolIsValid;public

c# - 如何将字符串转换为 DateTime as UTC 就这么简单

假设我有这个字符串:如何将它转换为具有UTC时间的DateTimeOffset对象-意味着-00:00作为时区-即使我在特定时区的机器上运行它?假设字符串:“2012-10-08T04:50:12.0000000”Convert.ToDateTime("2012-10-08T04:50:12.0000000"+"Z");-->日期时间d={10/8/20126:50:12AM}我希望它成为日期时间d={10/8/20124:50:12AM}好像它会理解我想要的日期一样简单(顺便说一句-我的机器在时区+02:00) 最佳答案 使用Da

c# - System.Net.Mail.SmtpException : The operation has timed out. 错误在asp.net发送邮件代码使用godaddy托管

我正在使用以下代码和平使用godaddy托管发送邮件。但它抛出System.Net.Mail.SmtpException:Theoperationhastimedout.protectedvoidsendmail(){varfromAddress="frommailid@site.com";//anyaddresswheretheemailwillbesendingvartoAddress="to@gmail.com";//PasswordofyourgmailaddressconststringfromPassword="mypassword";//Passingthevaluesa

c# - LinqToSQL 错误 : Operation is not valid due to the current state of the object

在更新命令期间,我收到以下错误:Operationisnotvalidduetothecurrentstateoftheobject我试图从更新命令中删除一列并且它工作正常。此列是一个FK,与其他工作正常的FK相似。这是执行更新的代码:ti.NumeroTitolo=titolo.Numero;ti.RKTipoTitoloGenereTitolo=titolo.RkTipoTitoloGenereTitolo;ti.RKBanca=titolo.RkBanca;ti.DataScadenza=titolo.DataScadenza;ti.RKTipoEsito=titolo.RkTi

c# - CA2104 警告 : Is there any way to mark a class as `Immutable` to suppress it?

考虑下面的代码,它触发了CA2104:Donotdeclarereadonlymutablereferencetypes.publicclassTest{//ThisprovokesCA2104:"Donotdeclarereadonlymutablereferencetypes".protectedreadonlyImmutableClassImmutableMember;}publicclassImmutableClass{}有谁知道以一种可以抑制警告CA2104的方式将类标记为不可变的方法吗?我尝试用[ImmutableObject(true)]装饰MutableClass没有成

c# - 为什么 is-operator 会导致不必要的装箱?

documentation与is运算符(exprisconstant)的常量模式匹配状态:Theconstantexpressionisevaluatedasfollows:Ifexprandconstantareintegraltypes,theC#equalityoperatordetermineswhethertheexpressionreturnstrue(thatis,whetherexpr==constant).Otherwise,thevalueoftheexpressionisdeterminedbyacalltothestaticObject.Equals(expr,