草庐IT

implicit-instantiation

全部标签

c# - 为什么 C# 使用 implicit void Main?

我不明白为什么C#的Main函数在默认情况下是无效的(例如在控制台项目中)。在C和C++中,标准明确规定main必须返回int,使用返回值是有意义的,因为我们可以检查来自外部程序的返回值,并查看C/C++应用程序是成功完成还是遇到错误。所以我的问题是:为什么VisualStudio将Main声明为void?一旦C#控制台应用程序执行完毕,向操作系统返回值的最佳方式是什么? 最佳答案 您可以使用int或void作为返回类型。因此,只需更改它并像在C++中那样返回一个值。为了不让新手迷惑,可能默认为void。

c# - "Cannot be determined because there is no implicit conversion"如果返回则为三进制

如果返回,我有以下ASP.NETWebApi2操作和三元:[HttpDelete]publicIHttpActionResultDelete(){booldeleted;//...returndeleted?this.Ok():this.NotFound();}我收到一个Typeofconditionalexpressioncannotbedeterminedbecausethereisnoimplicitconversionbetween'System.Web.Http.Results.OkResult'and'System.Web.Http.Results.NotFoundResu

c# - 错误 : Cannot implicitly convert type 'void' to 'System.Collections.Generic.List'

我正在尝试使用该控件从.ascx设置我的.ascx控件的属性。所以在我的一个包含此控件的.aspx中,我有以下代码试图设置我的嵌入式.ascx的ItemsList属性:Itemitem=GetItem(itemID);myUsercontrol.ItemList=newList().Add(item);我尝试设置的.ascx中的属性如下所示:publicListItemsList{get{returnthis.itemsList;}set{this.itemsList=value;}}错误:无法将类型“void”隐式转换为“System.Collections.Generic.List

javascript - 使用 PhantomJS 预渲染 AngualrJS 站点时出现 "Failed to instantiate module ngSanitize"

我正在尝试使用PhantomJS预呈现我的AngularJS网站。(使用来自http://www.yearofmoo.com/2012/11/angularjs-and-seo.html的phantomjs-runner.js)由于出现以下错误,我无法通过PhantomJS加载页面。在IE/Chrome/Firefox中不会出现此错误。我该如何解决这个错误?错误:Error:[$injector:modulerr]FailedtoinstantiatemoduleSpaceForAfricadueto:Error:[$injector:modulerr]Failedtoinstanti

javascript - `Cannot instantiate non-constructior` 关闭编译器警告?

亲爱的friend们,我应该如何处理ClosureCompiler输出的这些错误警告?非常感谢您对这种特定类型错误的想法和代码改进:JSC_WRONG_ARGUMENT_COUNT:函数parseInt:使用1个参数调用。函数需要至少2个参数且不超过2个参数。在第593行字符12if(parseInt(jQuery.browser.version)JSC_NOT_A_CONSTRUCTOR:无法实例化第708行字符15处的非构造函数lightbox=newLightbox(this,opts.lightbox);JSC_NOT_A_CONSTRUCTOR:无法实例化第1265行字符19

javascript - 未定义|0|引用错误 : Strict mode forbids implicit creation of global property 'csrf_token'

所以,这是我一直遇到的一个非常有趣的问题。我目前正在构建一个backbone.js-Rails应用程序。通常只是为了学习目的而构建它。我(就像任何优秀的Rails开发人员一样)在TDD/BDD方面尽力而为,但我遇到了capybara的问题。我有一个仅测试root_path工作的集成规范(主干历史开始、显示初始信息等...)。require'spec_helper'describe"RentalProperties",js:truedodescribe"GET/"doit"shouldshowalistofproperties"dovisitroot_patheventually{pag

javascript - typescript TS7015 : Element implicitly has an 'any' type because index expression is not of type 'number'

我在Angular2应用程序中遇到此编译错误:TS7015:Elementimplicitlyhasan'any'typebecauseindexexpressionisnotoftype'number'.导致它的代码是:getApplicationCount(state:string){returnthis.applicationsByState[state]?this.applicationsByState[state].length:0;}但这不会导致此错误:getApplicationCount(state:string){returnthis.applicationsBySt

javascript - 错误 TS7017 : Index signature of object type implicitly has an 'any' type in form validation angular 2

我在给出的Angular2中进行响应式(Reactive)验证时遇到编译错误errorTS7017:Indexsignatureofobjecttypeimplicitlyhasan'any'type为了this.comErrors[field]='';constmessages=this.validationMessages[field];this.comErrors[field]+=messages[key]+'';它正在按应有的方式运行,但是当我尝试运行npmrunbuild.prod时,出现错误并且无法构建我的项目这是我的代码:onValueChanged(data?:any)

javascript - 安装 Angular Material, "Failed to instantiate module ngMaterial"即使我使用的是 angular 版本 1.3.0

这非常令人沮丧,我使用的是mean.jsyeoman生成的应用程序,但似乎无法启动和运行AngularMaterial。我读了另一个关于这个问题的stackoverflow问题AngularjswithmaterialdesignFailedtoinstantiatemodulengMaterial.所以我更新了我的bower.json文件并运行了bowerupdate和bowerinstall。它仍然不起作用。在bower更新期间,bower给我这条消息Unabletofindasuitableversionforangular,pleasechooseone:,但我总是选择Angu

php - MVC : Instantiate Controller In Router?

我想弄清楚从路由器类中启动Controller是否是不好的做法。从我所能找到的一点点,有人说路由器不应该处理实例化Controller。下面是我如何开始开发我的路由器类。示例(注意为了打字我省略了很多。)classRouter{private$url,$controller;publicfunction__construct($url){$this->url=$url;$this->map();/*mapsurltocontrollerandaction*//*dispatchcontroller*/$this->dispatch();}privatefunctiondispatch(