草庐IT

parse_internal

全部标签

c# - 为什么 Enum.Parse() 返回对象?

这里有很多关于将字符串转换为枚举值的问题。通常,答案看起来类似于thisquestion上的答案。:StatusEnumMyStatus=(StatusEnum)Enum.Parse(typeof(StatusEnum),"Active",true);虽然这是一个非常合理的答案,并且您可以编写一个方法来简化调用,但它没有回答为什么Enum.Parse()返回object的问题。而不是适当的枚举值。为什么我必须将它转换为StatusEnum?编辑:基本上,问题是为什么像这样的函数不是Enum类的一部分?publicstaticTParse(stringvalue)whereT:struc

c# - 混淆 : Internal, 保护和保护内部

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Whatisthedifferencebetween'protected'and'protectedinternal'?WhatisthedifferencebetweenPublic,Private,Protected,andNothing?代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacetestanotherlib{publicclassA{internalvoidInt

C# float.Parse 字符串

我是C#新手,需要从文件中读取float值(x,y,z)。看起来像:0-0.01-0.0020.000833333333333-0.01-0.002如果我正在尝试floatnumber=float.Parse("0,54");//itworkswell,butfloatnumber=float.Parse("0.54");//gainsexepction.我从每一行读取值的代码(可能有问题):intbegin=0;intend=0;for(inti=0;i有人可以帮忙吗? 最佳答案 float.Parse(string)method

c# - 如何修复错误 : The message received from the server could not be parsed

我们有一个使用AJAX的Sharepoint解决方案。触发此操作的按钮位于更新面板内。我们所做的其中一件事是生成一个MSWord文档,然后在客户端上打开它以便打印。将文档发送到客户端的代码如下所示:voidOpenFileInWord(byte[]data){Response.Clear();Response.AddHeader("Content-Type","application/msword");Response.BinaryWrite(data);Response.Flush();Response.End();}我们得到的错误是:Message:Sys.WebForms.Pag

c# - TimeSpan.Parse 时间格式 hhmmss

在c#中,我有hhmmss格式的时间,例如12:45:10的124510,我需要知道TotalSeconds。我使用了TimeSpan.Parse("12:45:10").ToTalSeconds但它不采用hhmmss格式。有什么好的方法可以转换它吗? 最佳答案 这可能有帮助usingSystem;usingSystem.Globalization;namespaceConsoleApplication7{classProgram{staticvoidMain(string[]args){DateTimed=DateTime.Par

c# - 最好使用 int.Parse 或 Convert.ToInt32

这个问题在这里已经有了答案:关闭12年前。PossibleDuplicate:Whatsthemaindifferencebetweenint.Parse()andConvert.ToInt32我想知道使用Convert.ToInt32VSint.Parse的优点和缺点是什么。这里是我使用的语法示例:intmyPageSize=Convert.ToInt32(uxPageSizeUsersSelector.SelectedValue);intmyPageSize=int.Parse(uxPageSizeUsersSelector.SelectedValue);我也找到了这些文章,也许他

c# - "private"和 "protected Internal"有什么区别?

我只想知道private和protectedinternal访问说明符之间的实际区别是什么。据我所知Visibletoownclassmembers:privateandprotectedinternalYESVisibletoobjectofotherclasses:BothNOVisibletoobjectsofotherclassesoutsidethenamespacecollection:BothNOVisibletoobjectofchildclassesoutsidethenamespacecollection:BothNO如果private与protectedinter

c# - XDocument.Parse 成功还是失败?

我正在使用XDocumentdoc=XDocument.Parse(somestring);但是我如何验证字符串somestring是否是格式正确的XML。TryCatch是执行此操作的唯一方法吗? 最佳答案 IsTryCatchtheonlywaytodothis?XDocument没有TryParse方法,因此try-catch可能是最好的选择。还要考虑根据模式验证您的XML,因为它不仅会检查XML是否格式正确,还会检查约束。您可能会看到:ValidationAgainstXMLSchema(XSD)withtheXmlVali

c# - HTML 敏捷包 : parsing an href tag

我如何从中有效地解析href属性值:7D.KulikovD000[...]我对播放器ID很感兴趣,它是:8475179这是我目前拥有的代码://Iterateallrows(players)for(inti=1;i 最佳答案 根据您的示例,这对我有用:HtmlDocumenthtmlDoc=newHtmlDocument();htmlDoc.Load("test.html");varlink=htmlDoc.DocumentNode.Descendants("a").First(x=>x.Attributes["class"]!=n

c# - 'System.Data.Entity.Internal.AppConfig' 的类型初始值设定项在子网站上抛出异常

我有2个网站,一个是另一个的子目录,但它是一个应用程序例如:/root&/root/Services他们都使用EntityFramework6.x但子网站正在抛出ThetypeinitializerforSystem.Data.Entity.Internal.AppConfig'throwanexception因为它似乎看到了许多条目由于嵌套的web.config而用于相同的EF数据库提供程序有没有办法清除提供程序集合,这样我就不会收到此错误?我试过没有效果。如果我注释掉providers部分就可以了但我不想这样做,因为并非每个环境都会有嵌套网站。并且NuGet倾向于将其放回原处。我可