我得到了
参数计数不匹配
错误.它出现在该if
条款中.我的代码:
private Dictionary<string,string> ObjectToDict(Dictionary<string, string> dict, object obj)
{
var properties = obj.GetType().GetProperties();
foreach (var property in properties)
{
if (property.GetValue(obj, null) != null)
dict["{{" + property.Name + "}}"] = property.GetValue(obj, null).ToString();
}
return dict;
}
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为当我将property
值添加到字典时它可以正常工作,但是当我测试它是否null
在if
子句中时却没有.
我发现的所有问题都是在函数调用中输入了不正确数量的参数,但是AFAIK在我的两个调用之间没有什么不同.
这是我的简单课程:
public class Project {
private int size;
private Obj tree;
static Obj insert( Obj t, String s ) { // t is null
t = new Obj();
t.val = s;
return t;
}
public Project()
{
Obj tree = new Obj();
int size=0;
}
public class Obj
{
public String val;
public Obj()
{
val=null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试在insert()函数中创建一个新对象时,我收到此错误:
Error: non-static variable this cannot be referenced from a static context
Run Code Online (Sandbox Code Playgroud) 我试过谷歌搜索,但谷歌没有很好地处理"--n".我在教授的代码中看到了这个:
f[--n];
f[n++];
Run Code Online (Sandbox Code Playgroud)
其中f是double值的数组.
我的猜测是它在减少(或添加)到n之前返回f [n]的值.
所以我试图复制这个答案Getting cell-backgroundcolor in Excel with Open XML 2.0
但 VS 抱怨SpreadsheetReader
在当前上下文中不存在。我无法解决ctrl+.
这个问题。
这是(几乎可以工作)代码:
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
public static DocumentFormat.OpenXml.Drawing.PatternFill GetCellPatternFill(Cell theCell, SpreadsheetDocument document)
{
WorkbookStylesPart styles = SpreadsheetReader.GetWorkbookStyles(document);
int cellStyleIndex;
if (theCell.StyleIndex == null) // I think (from testing) if the StyleIndex is null
{ // then this means use cell style index 0.
cellStyleIndex = 0; // However I did not found it in the open xml
} // specification.
else
{ …
Run Code Online (Sandbox Code Playgroud) 所以这是我的函数,用于AJAX调用:
public void Button1_Click(object sender, EventArgs e)
{
Button1.Text = "surprise";
Label1.Text = "surprise!!";
Label2.Text = "surprise!!";
}
Run Code Online (Sandbox Code Playgroud)
这是aspx
.Scriptmanager已设置.
<p>Síðast slóstu inn:
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
</p>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server">asd</asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server">dsa</asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)
如果你愿意,你可以自己看看:http://webapplication44730.azurewebsites.net/data
正如你所看到的,按钮上的文字更改为"惊喜",但唱片公司,Label1
并Label2
在这之后应该会出现"旅店,"没有.