我有一个页面,我必须根据用户选择动态加载控件.让我们说我有这样的事情:
public static readonly Dictionary<string, string> DynamicControls = new Dictionary<string, string>
{
{ "UserCtrl1", "~/Controls/UserCtrl1.ascx" },
{ "UserCtrl2", "~/Controls/UserCtrl2.ascx" },
{ "UserCtrl3", "~/Controls/UserCtrl3.ascx" },
{ "UserCtrl4", "~/Controls/UserCtrl4.ascx"}
};
Run Code Online (Sandbox Code Playgroud)
现在让我们说,而不是在加载控件的页面上,代码是这样的:
protected void Page_Load(object sender, EventArgs e)
{
SomePanel.Controls.Add(GetControl());
}
private Control GetControl()
{
string dynamicCtrl = CurrentItem.DynamicControl;
string path = SomeClass.DynamicControls[dynamicCtrl];
Control ctrl = null;
//TODO: find a better way to load the controls
switch (dynamicCtrl)
{
case "UserCtrl1":
{
ctrl = (UserCtrl1)LoadControl(path);
}
break;
case "UserCtrl2":
{
ctrl = (UserCtrl2)LoadControl(path); …Run Code Online (Sandbox Code Playgroud) 这一行:
strcat(query,*it);
Run Code Online (Sandbox Code Playgroud)
(*it字符串的迭代器在哪里)
继续给我这个错误:
没有匹配函数来调用``strcat(char [200],const std :: basic_string,std :: allocator>&)`'
我想这是因为strcat花费一段char*时间*it是一个字符串.如何将其从字符串转换char*为使其适用strcat()?
我试过strcat(query,(*it).c_str())但只是给了我一个运行时错误.
编辑:抱歉,它应该转换为 const char*
我有一堆通用接口和类
public interface IElement {
// omited
}
class Element implements IElement {
// omited
}
public interface IElementList<E extends IElement> extends Iterable {
public Iterator<E> iterator();
}
class ElementList implements IElementList<Element> {
public Iterator<Element> iterator() {
// omited
}
}
public interface IElementListGroup<E extends IElementList<? extends IElement>> {
public E getChosenElementList();
}
class ElementListGroup implements IElementListGroup<ElementList> {
public ElementList getChosenElementList() {
// omited
}
}
Run Code Online (Sandbox Code Playgroud)
然后是一个简单的代码
ElementListGroup group;
for(Element e : group.getChosenElementList())
{
// omited
}
Run Code Online (Sandbox Code Playgroud)
而对于关键字throwe的行"无法从元素类型Object转换为Element"编译器错误.
提前致谢.
package pkg_1;
public class ExpOnWaitMethod extends Thread {
static Double x = new Double(20);
public static void main(String[] args) {
ExpOnWaitMethod T1 = new ExpOnWaitMethod();
ExpOnWaitMethod T2 = new ExpOnWaitMethod();
T1.start();
T2.start();
}
public void run() {
Mag mag = new Mag();
synchronized (x) {
try {
for (int i = 1; i < 10; i++) {
mag.nop(Thread.currentThread());
x = i * 2.0;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class Mag {
char ccc = …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个计划程序,它将标记列表作为输入,并将输出作为等级列表.
我到目前为止,...我不知道什么是错的我得到一个错误,对象()作为第一个参数传递给cdr不是正确的类型....
这是代码
(define (grades list1)
(cons (cond ((= (car list1) 100) 'S)
((= (car list1) 90) 'A))
(cons (grades (cdr list1)) '())))
Run Code Online (Sandbox Code Playgroud) 或者更确切地说,为什么(= 1e16 (- 1e16 1))返回真实?我怎样才能收到更准确的答案?
使用mit-scheme尝试一些Lisp。
(define (inv curstate x y)
((cond (= y 1) curstate)
(cond (even? y)
(inv (square curstate) x (/ y 2)))
(else
(inv (* x curstate) x (- y 1)))))
Run Code Online (Sandbox Code Playgroud)
解释器错误:
格式错误的子句:curstate
另一个版本使用线性递归方法,因此存在类似的错误。该怎么办?
scheme ×4
lisp ×3
java ×2
asp.net ×1
c# ×1
c++ ×1
char ×1
concurrency ×1
refactoring ×1
string ×1