小编Sas*_*sky的帖子

返回共享方法的两种不同类型的可能对象之一

我有2个班:

public class Articles
{
    private string name;

    public Articles(string name)
    {
        this.name = name;
    }

    public void Output()
    {
        Console.WriteLine("The class is: " + this.GetType());
        Console.WriteLine("The name is: " + name);
    }
}
Run Code Online (Sandbox Code Playgroud)

public class Questionnaire 
{
    private string name;

    public Questionnaire(string name)
    {
        this.name = name;
    }

    public void Output()
    {
        Console.WriteLine("The class is: " + this.GetType());
        Console.WriteLine("The name is: " + name);
    }
}
Run Code Online (Sandbox Code Playgroud)

我想写一个方法,它取一个整数(1表示Articles应该返回,2表示意思Questionnaire)和一个名字.

此方法必须返回这两个类之一的实例:

public [What type??] Choose(int x, string …
Run Code Online (Sandbox Code Playgroud)

.net c# oop duck-typing factory-pattern

18
推荐指数
4
解决办法
9311
查看次数

调用栈只包含外部代码

我希望当我点击另一个变得可见时。我是用 jQuery 做的,但我不擅长。我写的脚本:

    <script type="text/javascript">
        $(document).ready(function () {
            $('.visiblePanel').on('click', function () {
                $('.invisiblePanel').toggle();
            });
        });
    </script>
Run Code Online (Sandbox Code Playgroud)

我已经完成的布局?#:

Panel visiblePanel = new Panel();
visiblePanel.Style.Add("background-color", "red");
visiblePanel.CssClass = "visiblePanel";
Panel invisiblePanel = new Panel();
invisiblePanel.CssClass = "invisiblePanel";
Run Code Online (Sandbox Code Playgroud)

当然,它没有奏效。但也会出现错误: 在此处输入图片说明

没有脚本一切都很好。我试图禁用 Just My Code 并得到了:

在此处输入图片说明 真的,我用谷歌搜索了该怎么做,但没有成功。你可以帮帮我吗?

PS 在 jsfiddle.net 上我的脚本正在运行。 http://jsfiddle.net/ZMxg8/

PPS:问题不在脚本中!VS怎么了??“调用堆栈只包含外部代码”是什么意思???

.net c# asp.net visual-studio-2012

6
推荐指数
1
解决办法
7490
查看次数

旋转M*N矩阵(90度)

我该如何旋转矩阵

|3 4 5 6 8|
|5 4 3 2 6|
|3 3 7 8 9|
Run Code Online (Sandbox Code Playgroud)

|8 6 9|            
|6 2 8|
|5 3 7|
|4 4 3|
|3 5 3|
Run Code Online (Sandbox Code Playgroud)

因为我见过的所有算法都是N*N矩阵.

c# algorithm rotation matrix

6
推荐指数
1
解决办法
1万
查看次数

从List <string>到Dictionary <string,string>

我有名单

List<string> listOfAtt = new List<string>();
Run Code Online (Sandbox Code Playgroud)

在那里listOfAtt[0] = "FirsName",listOfAtt[1] = "Homer"等等.

我怎样才能创造出Dictionary<srting,string>这种类型

listOfAtt["FirsName"] = "Homer"???

.net c#

1
推荐指数
2
解决办法
191
查看次数