小编arj*_* kr的帖子

visual studio代码中的launch.json和task.json有什么区别?

为什么我们有两种配置来在Visual Studio Code中设置构建环境?他们之间有什么区别?

visual-studio-code

15
推荐指数
1
解决办法
3249
查看次数

为什么Array(1).join('str')输出为空?

为什么下面的代码块不输出字符串?

当我们传递num = 1时,我期待它应该显示abc.

我在这里缺少什么?

function repeatStringNumTimes(str, num) {
  return Array(num).join(str);
}
console.log(repeatStringNumTimes("abc", 1));
Run Code Online (Sandbox Code Playgroud)

javascript

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

我在“设置”属性下面的行为是什么?

我试图创建简单的事件,下面是代码块,但它不起作用。当我尝试调试时,一旦我们创建Point对象,它就会在“ Set”属性上抛出“ StackOverFlowException”(甚至在我们分配值px = 10之前)。我做错了什么?

using System;

namespace Workshop
{

    public class Point
    {
        public int x
        {
            get { return x; }
            set
            {
                x = value;
                onPointeChanged();
            }
        }

        public int y
        {
            get { return y; }
            set
            {
                y = value;
                onPointeChanged();
            }
        }

        public event EventHandler pointchanged;

        private void onPointeChanged()
        {
            if (pointchanged != null)
                pointchanged(this, EventArgs.Empty);
        }

    }

    public class Program
    {

        public static void Main(String[] args)
        {
            Point p = new Point();
            p.pointchanged …
Run Code Online (Sandbox Code Playgroud)

c#

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

在执行IEnumerable <T>方法之前,方法如何在C#中返回结果?

在代码块下面,显示MyList中大于2的数字.

using System;
using System.Collections.Generic;
namespace CSharpBasics
{
    internal class Program
    {
        private static List<int> MyList = new List<int>();
        private static void Main(string[] args)
        {
            MyList.Add(1);
            MyList.Add(2);
            MyList.Add(3);
            MyList.Add(4);
            var test = FilterWithYield();
            foreach (int i in test)
            {
                Console.WriteLine(i);
            }
            Console.ReadLine();
        }
        private static IEnumerable<int> FilterWithYield()
        {
            foreach (int i in MyList)
            {
                if (i > 2)
                {
                    yield return i;
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,当我们将断点设置为line时foreach (int i in test),在执行 foreach 循环之前,test …

c# yield

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

标签 统计

c# ×2

javascript ×1

visual-studio-code ×1

yield ×1