草庐IT

Non-Zero

全部标签

c# - 错误 : "an object reference is required for the non-static field, method or property..."

这个问题在这里已经有了答案:CS0120:Anobjectreferenceisrequiredforthenonstaticfield,method,orproperty'foo'(9个回答)关闭5年前。我正在用C#创建一个应用程序。它的功能是评估给定的是否为素数以及相同的交换数是否也是素数。当我在VisualStudio中构建我的解决方案时,它说“非静态字段、方法或属性需要对象引用...”。我在使用“volteado”和“siprimo”方法时遇到了这个问题。问题出在哪里,我该如何解决?namespaceConsoleApplication1{classProgram{static

C# 错误 : "An object reference is required for the non-static field, method, or property"

我有两个类,一个用于定义算法参数,另一个用于实现算法:1类(算法参数):usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceVM_Placement{publicstaticclassAlgorithmParameters{publicstaticintpop_size=100;publicstaticdoublecrossover_rate=0.7;publicstaticdoublemutation_rate=0.001;publicstaticintchrom

c# - MVC : The parameters dictionary contains a null entry for parameter 'k' of non-nullable type 'System.Int32'

我是MVC的新手。在我的应用程序中,我正在从Mydatabase中检索数据。但是当我运行我的应用程序时,它会显示这样的错误这是我的网址http://localhost:7317/Employee/DetailsData/4ExceptionDetails:System.ArgumentException:Theparametersdictionarycontainsanullentryforparameter'k'ofnon-nullabletype'System.Int32'formethod'System.Web.Mvc.ActionResultDetailsData(Int32)

c# - .Net 中 Decimal.One、Decimal.Zero、Decimal.MinusOne 的用途是什么

简单的问题-为什么Decimal类型定义这些常量?何必呢?我正在寻找一个原因,为什么这是由语言定义的,而不是可能的用途或对编译器的影响。为什么首先把它放在那里?编译器可以像Decimal.Zero一样轻松地内联0m,因此我不会将其作为编译器快捷方式购买。 最佳答案 小澄清。它们实际上是静态只读值而不是常量。这在.Net中有明显的区别,因为常量值被各种编译器内联,因此不可能在编译的程序集中跟踪它们的使用情况。然而,静态只读值不会被复制,而是被引用。这对您的问题是有利的,因为这意味着可以分析它们的使用。如果您使用反射器并深入研究BCL,

c# - 可空类型 : better way to check for null or zero in c#

我正在做一个项目,我发现我在很多很多地方检查以下内容:if(item.Rate==0||item.Rate==null){}更多的是好奇,检查这两种情况的最佳方法是什么?我添加了一个辅助方法,它是:publicstaticboolnz(objectobj){varparsedInt=0;varparsed=int.TryParse(obj.ToString(),outparsedInt);returnIsNull(obj)||(parsed&&parsedInt==0);}有没有更好的办法? 最佳答案 我喜欢if((item.Rat

c# - 为什么我会收到消息 "Invalid setup on a non-virtual (overridable in VB) member..."的异常?

我有一个单元测试,我必须模拟一个返回bool类型的非虚拟方法publicclassXmlCupboardAccess{publicboolIsDataEntityInXmlCupboard(stringdataId,outstringnameInCupboard,outstringrefTypeInCupboard,stringnameTemplate=null){returnIsDataEntityInXmlCupboard(_theDb,dataId,outnameInCupboard,outrefTypeInCupboard,nameTemplate);}}所以我有一个XmlCu

javascript - 错误 : [$compile:nonassign] Expression 'undefined' used with directive 'myFacebook' is non-assignable

我正在用angularjs编写一个指令并得到上面提到的错误。我正在使用一本书中的代码。.directive('myFacebook',[function(){return{link:function(scope,element,attributes){(function(d){varjs,id='facebook-jssdk',ref=d.getElementsByTagName('script')[0];if(d.getElementById(id)){return;}js=d.createElement('script');js.id=id;js.async=true;js.src

转到 1.12 模块 : local import in non-local import

我目前正在使用Go1.12模块并且对导入感到厌烦。我正在使用gin(网络微服务)和gorm(golangorm)制作rest-api。在golang模块中工作时一切仍然正常。但是在导入本地包时遇到问题目录树:go.mod:modulegithub.com/Aragami1408/go-gormgo1.12require(github.com/gin-gonic/ginv1.4.0github.com/jinzhu/gormv1.9.9github.com/lib/pqv1.1.1github.com/satori/go.uuidv1.2.0)db.go:packagedb//codeb

使用 Pygame Zero 构建一个捕捉游戏(详细步骤含源码)

Pygamezero是一个用于教育的工具,适合任何开始学习使用Python创建游戏的人。那么让我们从制作一个小的捕捉游戏开始吧:)您可以使用pip安装pygame零,如图所示pipinstallpgzero你好Pygamezero!要开始使用pygamezero,请将以下代码复制到文件catching_game.pyimportpgzrunWIDTH=800HEIGHT=600pgzrun.go()这将创建一个WIDTH800和HEIGHT600的屏幕。要运行它,请在终端中键入以下内容pythoncatching_game.py准备在开始编写其余代码之前,让我们收集所需的图像和声音。在您的主项

golang - 将枚举类型保存到 SQL 数据库 "panic: sql: converting Exec argument #1' s 类型 : non-Value type int returned from Value"

在我当前的go项目(~5KLOC)中,我使用sqlite3作为我的底层数据库层,我使用gorm作为我的ORM引擎。其中一个模型是一个Platform,其字段为PlatformType枚举类型。这是演示我的问题的代码片段。packagemainimport(_"github.com/jinzhu/gorm/dialects/sqlite""github.com/jinzhu/gorm""database/sql/driver""fmt")/****************************\ObjectLayer\****************************///Pla