草庐IT

non-primitive

全部标签

c# - 消息 : Invalid JSON primitive: ajax jquery method with Webmethod

我使用数据值作为对象字面量,而不是像thisanswer中解释的那样连接一个字符串我的代码如下:$.ajax({url:"../Member/Home.aspx/SaveClient",type:"POST",async:false,dataType:'json',contentType:'application/json;charset=utf-8',data:{"projectSoid":ProjectId,"startDate":StartDate,"endDate":EndDate,"clientManager":ClientManager},success:function(

c# - 获取 C# 字符串的 NON FIRST 段的快速而巧妙的方法

我对一个字符串执行split(''),我想提取返回字符串的第一个元素以获得字符串的其余部分。f.e.“这是一个了不起的字符串”.split('');我想得到除THIS之外的所有单词。这是:是一个惊人的字符串字符串在第一个和第二个单词之间总是至少有一个空格,因为我会把它硬编码是否有实现此功能的功能?谢谢 最佳答案 尝试stringX="THISISANAMAZINGSTRING";stringY=(X.IndexOf("")根据评论(IFX保证是至少有一个空格的有效字符串)没有检查等的更简单版本:stringY=X.Substring

c# - "Primitive types"与 "built-in value types"

我最近在使用Array.SetValue(Int32)方法时捕获了C#中的异常。异常(exception)是:Cannotwidenfromsourcetypetotargettypeeitherbecausethesourcetypeisanotaprimitivetypeortheconversioncannotbeaccomplished.提到“原始”这个词让我有点吃惊,因为我认为趋势是将这些类型称为内置类型,而且术语“原始类型”是一个非正式术语。“原始”类型和“内置值类型”有什么区别?我在C#语言规范中找不到原始类型的定义。 最佳答案

C# 编译器 : cannot access static method in a non-static context

我有下面的代码:publicclassAnything{publicintData{get;set;}}publicclassMyGenericBase{publicvoidInstanceMethod(Tdata){//dosomejob}publicstaticvoidStaticMethod(Tdata){//dosomejob}//othersmembers...}publicsealedclassUsefulController:MyGenericBase{publicvoidProxyToStaticMethod(){StaticMethod(null);}//others

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# - 为什么我会收到消息 "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

c# - Ajax处理中的"Invalid JSON primitive"

我在jQuery的ajax调用中遇到错误。这是我的jQuery函数:functionDeleteItem(RecordId,UId,XmlName,ItemType,UserProfileId){varobj={RecordId:RecordId,UserId:UId,UserProfileId:UserProfileId,ItemType:ItemType,FileName:XmlName};varjson=Sys.Serialization.JavaScriptSerializer.serialize(obj);$.ajax({type:"POST",url:"EditUserPr

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