草庐IT

out_of_range

全部标签

windows - cmd 相当于 std::string::find_first:of

C++、Java、JavaScript和其他可能的编程语言都有一个字符串函数,可以在字符串中搜索指定字符串模式中的任何字符。例如,C++的std::string::find_first_of像这样工作:std::coutCMD中是否有任何等效项?我尝试搜索“dos字符串函数”,但似乎找不到任何内容。 最佳答案 没有直接的方法,但您可以很容易地编写自己的方法。搜索一个字符@echooffcall:charposition"Searchmeforvowels"aposechoFoundaatposition%pos%goto:eof:c

windows - Powershell 脚本 : Can't read return value of executed program

我正在使用PowerShell运行一个脚本,该脚本执行wget以获取网页(一个简单的数据库导入脚本)并分析其输出(错误消息或“OK”)。我正在使用thispreviousquestion的答案中的代码我的。$a=c:\path_to_wget\wget.exe--quiet-O-"http://www.example.com/import_db"$rc=$a.CompareTo("OK")exit$rc当wget操作的结果是404-并且wget可能返回错误级别1或127-我从PowerShell收到以下错误消息:Youcannotcallamethodonanull-valuedexp

Java - 带有 System.out.println() 的 Mac/Windows

我们大部分时间都在IDE的控制台中使用System.out.println。我正在使用Eclipse。我还可以在Mac的控制台应用程序上清楚地看到println()消息。这对我个人的东西很好。代码如下:publicclassMain{publicstaticvoidmain(String[]args){System.out.println("Isthisloggedanywhere?");}}这是我在Mac上看到的:Windows是否有类似于Mac版本的控制台? 最佳答案 遗憾的是,如前所述,我们在Windows上并没有真正做到这一

windows - PE : Relation between SizeOfRawData and VirtualSize fields of the section header

我看到对于图像文件中的部分,VirtualSize字段是加载到内存中时部分的总大小,而SizeOfRawData字段是部分的大小磁盘上的初始化数据。在检查.idata部分时,VirtualSize字段设置为0x14,而SizeOfRawData字段设置为0x400。为什么链接器-在本例中为MinGWld-使文件部分如此之大,而加载到内存中的部分只是其大小的一小部分?此外,VirtualSize字段的用途是什么?为什么不总是加载整个部分,即加载SizeOfRawData字节?我在官方PE文档中没有看到描述或它们之间的关系。 最佳答案

c# - 如何准确测量 Azure Web 应用程序中的 "data out"?

我在Azure中有一个网络应用程序,每月大约有10万访问者,每次session的页面浏览量不到2(纯SEO访问者)。我刚刚研究了我们的Azure账单,震惊地发现上个月我们输出了3.41TB的数据。太字节。这完全没有意义。我们的平均页面大小小于3mb(很多,但不是数学上说的30mb)。实际上,输出的总数据应该是:3431000(mb)/150000(sessions)=23mbprsession,这绝对是假的。Pingdom等服务的结果说:(似乎Stack.Imgur已关闭-临时链接:http://prntscr.com/gvzoaz)我的图表看起来像这样,它不是刚出现的东西。我已经有一

c# - 异常:指定类别中不存在实例 'Name of instance'

当我像这样创建和使用性能计数器时:privatereadonlyPerformanceCounter_cpuPerformanceCounter;publicProcessViewModel(Processprocess){_cpuPerformanceCounter=newPerformanceCounter("Process","%ProcessorTime",process.ProcessName,true);}publicvoidUpdate(){CPU=(int)_cpuPerformanceCounter.NextValue()/Environment.ProcessorC

c# - 空传播运算符、out 参数和错误的编译器错误?

假设我有一个类,其属性类型为Dictionary,那可能是空的。这会编译但调用TryGetValue()可以抛出NullRef运行时异常:MyClassc=...;stringval;if(c.PossiblyNullDictionary.TryGetValue("someKey",outval)){Console.WriteLine(val);}所以我添加了一个null传播运算符来防止null,但这不会编译:MyClassc=...;stringval;if(c.PossiblyNullDictionary?.TryGetValue("someKey",outval)??false)

c# - 如何使用反射调用带有 ref/out 参数的方法

假设我有以下类(class):classCow{publicstaticboolTryParse(strings,outCowcow){...}}是否可以通过反射调用TryParse?我知道基础知识:vartype=typeof(Cow);vartryParse=type.GetMethod("TryParse");vartoParse="...";varresult=(bool)tryParse.Invoke(null,/*whataretheargs?*/); 最佳答案 你可以这样做:staticvoidMain(string[

c# - 存储库模式 : Implementation and lazy loading of model relationships

我有一个处理产品和产品类别的应用程序。对于其中的每一个,我都有使用POCO定义的模型。//Representsaproduct.classProduct{publicvirtualintID{get;set;}publicvirtualstringName{get;set;}publicvirtualProductCategoryCategory{get;set;}}//Representsaproductcategory.classProductCategory{publicvirtualintID{get;set;}publicvirtualstringName{get;set;}

c# - 为什么我可以通过索引访问 KeyCollection/ValueCollection 中的项目,即使它没有实现 IList(Of Key)?

我注意到一个奇怪的VB.NET东西。来自thisquestion我提供了一种访问字典的键和值的方法'KeysCollection和ValuesCollection通过索引获取第一项。我知道它只在SortedDictionary中才有意义因为正常Dictionaryisnotordered(好吧,你不应该依赖它的顺序)。这是一个简单的例子:DimsortedDictAsNewSortedDictionary(OfDateTime,String)sortedDict.Add(DateTime.Now,"Foo")DimkeysAsSortedDictionary(OfDateTime,St