草庐IT

datetime-parsing

全部标签

c# - 无效的 URI : The Authority/Host could not be parsed from very long url

这是Youtube视频的实际url,此时如果您复制到您的chrome浏览器,您可以观看该视频。但是,当我尝试创建请求时,我得到了UriFormatException。我做错了什么?HttpWebRequestrequest=(HttpWebRequest)HttpWebRequest.Create(url);http:/r6---sn-x5jjxnn-ogul.googlevideo.com/videoplayback?ratebypass=yes&ms=au&fexp=924615,912522,932260,910207,936330,916611,936117,936910,93

c# - 我必须如何更改此 XML 字符串以便 XDocument.Parse 读取它?

在下面的代码中,我将一个对象序列化为一个XML字符串。但是当我尝试使用XDocument.Parse将此XML字符串读入XDocument时,它给了我这个错误:Invaliddataatrootlevel.XML是:1JimJones23434更新:这是十六进制:![alttext][1]Mod编辑-禁用超链接:指向恶意软件的链接我必须对该XML做什么才能使其无错误地读入XDocument?usingSystem;usingSystem.Collections.Generic;usingSystem.Xml.Serialization;usingSystem.IO;usingSyste

c# - long.Parse() C#

我如何在C#中将字符串(例如“-100,100”)转换为long。我目前有一行代码是longxi=long.Parse(x,System.Globalization.NumberStyles.AllowThousands);但是当x是“负数”时,这会中断。我的方法:longxi=long.Parse("-100,253,1",System.Globalization.NumberStyles.AllowLeadingSign&System.Globalization.NumberStyles.AllowThousands);错了,因为它坏了。 最佳答案

c# - 如何管理将 DateTime 的空对象解析为 DBNULL 与 ADO.NET 一起使用

我有两个DateTime对象,BirthDate和HireDate。它们被正确地格式化为字符串,当我将它们传递到我的数据访问层时,它们需要被解析为DateTime对象。DateTimehD=DateTime.Parse(hire);DateTimebD=DateTime.Parse(birth);//incaseofadatestringbeingpassedthroughdateStringPassed="7/2/1969";但有时,字符串hire和birth为null或为空"",如果代码像这样运行,我会得到一个解析空字符串时出现FormatException错误。如何管理空解析并允

c# - 将字符串转换为 C# UK 和 US 格式的 DateTime

我正在尝试将字符串转换为日期时间我一直在用DateTimeconvertedDate=DateTime.Parse(lastModificationDate);转换日期我的问题是,有时日期是英国格式,有时是美国格式即英国11/09/201110:34美国2/28/201013:56当我不确定字符串的格式是us还是uk时,如何处理这两种格式? 最佳答案 你根本做不到。你没有足够的数据。作为一个人,这里涉及到哪个日期?11/09/201110:34那是9月11日还是11月9日?如果您人类无法分辨差异,那么计算机就不可能做到。现在,如果您

c# - DateTime.ParseExact() 比 DateTime.Parse() 快吗

我想知道ParseExact是否比Parse快。我认为它应该是ParseExact,因为您已经提供了格式,但我也认为所有对文化信息的检查都会减慢它的速度。微软是否在任何文件中说明了两者之间的性能差异。要使用的格式是通用的“yyyy/MM/dd”格式。例如:DateTime.Parse(DateText);DateTime.ParseExact(DateText,"yyyy/MM/dd",CultureInfo.InvariantCulture); 最佳答案 您要求两种功能不同(接近但仍然不同)的方法在速度上存在差异。只需选择最合适的

c# - 单声道缺少 System.Numerics.BigInteger.Parse(string,IFormatProvider)

我目前在使用Json.NET/Newtonsoft.JSON时遇到以下错误图书馆:MissingmethodSystem.Numerics.BigInteger::Parse(string,IFormatProvider)inassembly/usr/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll,referencedinassembly~/dev/Mono/Mercury/Mercury/bin/Debug/Newtonsoft.Json.dll每当从couchDB数据库中检索到的J

c# - 为什么 DateTime.Now 需要线程安全?

我正在阅读Joe的AlbahariC#threadingtutorial:作者解释了为什么DateTime.Now需要线程安全:Wrappingaccesstoanobjectaroundacustomlockworksonlyifallconcurrentthreadsareawareof—anduse—thelock.Thismaynotbethecaseiftheobjectiswidelyscoped.Theworstcaseiswithstaticmembersinapublictype.Forinstance,imagineifthestaticpropertyontheD

c# - 如何在 Entity Framework 中使用 DateTime.AddDays(x)

我有这个代码:fromprine.ProgramSetup.Include("Program").Include("Program.Client")wherepr.DateBeginDateTime.Now.AddDays(pr.DateEndOffset)selectpr).ToList();它不起作用,因为AddDays()不可能用于生成sql。那么还有别的办法吗?现在我选择所有内容并最终通过foreach对其进行过滤,但我认为这不是好方法。问题是pr.DateEndOffset也只在db中,它不是常量... 最佳答案 usin

c# - C# 中的 DateTime.MinValue 与 new DateTime()

当获取SQL日期时间时,Resharper建议在值为DBNull.Value时使用newDateTime()。我一直使用DateTime.MinValue。哪种方法正确?DateTimevarData=sqlQueryResult["Data"]isDateTime?(DateTime)sqlQueryResult["Data"]:newDateTime(); 最佳答案 来自thedocumentationofDateTime.MinValue:MinValuedefinesthedateandtimethatisassignedt