如果我将项目多目标定位到 .Net Core 3.1 和 .Net Framework 4.8 并且我选择了调试 | 开始调试,Visual Studio 2019 开始与 .Net Framework 构建目标的调试会话。
我怎样才能让它启动 .Net Core 构建目标?
这是我的测试项目文件:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net48;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
这是测试代码:
using System;
namespace Demo
{
class Program
{
public static void Main(string[] args)
{
#if NET48
Console.WriteLine(".Net Framework");
#else
Console.WriteLine(".Net Core");
#endif
}
}
}
Run Code Online (Sandbox Code Playgroud)
项目中没有其他文件。我使用的是 Visual Studio 2019 版本 16.7.2。
给出一些重复的单词序列,例如:
var words = "one two three two four five six four seven four eight".Split(' ');
Run Code Online (Sandbox Code Playgroud)
您可以找到这样的重复项您可以将这样的单词分组:
var g1 = words.GroupBy(w => w);
Run Code Online (Sandbox Code Playgroud)
我试图将其重写为Linq Query sytnax,只是为了看看它是什么样的(我知道在实际代码中你会像上面的那行一样离开它!).
我认为Linq I看起来比它应该复杂得多.怎么简化?它和上面的线真的一样吗?
var g2 = from w in words group w by w into g select g;
Run Code Online (Sandbox Code Playgroud)
(我想我正在进行一次星期日大脑褪色...;)
[编辑]我对这个惊叹的来源是从前面这个问题的答案.
关于传值和传递引用之间差异的MS帮助页面对我来说非常清楚:
http://msdn.microsoft.com/en-us/library/8b0bdca4.aspx
但是,最后的用户评论让我感到困惑.它说(除其他外)这个:
如果不使用ref或out关键字,则方法的参数按值传递.
评论对我来说似乎很不对劲.是吗?
(我发布的部分评论断章取义:这是完整的评论:)
文字说:"......但是当传递一个类实例时,会传递一个引用...."这是不正确的,你可以在下面看到:
C#语言规范版本4.0(Microsoft免费下载)5.1.4值参数声明没有ref或out修饰符的参数是值参数.
因此,在上面的示例中,类实例按值传递,而不是通过引用传递.
这是完整的评论,这让我很困惑......类实例是按值而不是通过引用传递的?这是否意味着实例字节被压入堆栈?
public static int atk = 5;
public static void main(String[] args){
System.out.println("DUNGEONS AND DWAGONS");
Scanner scan = new Scanner(System.in);
help();
String input = scan.next();
// when someone types help first it works, but when they type stats after it shows what would happen if someone typed help.
while(true){
if (input.equals("help")){
help();
scan.next();
}else if(input.equals("stats")){
stats();
scan.next();
}
}
}
static void help() {
System.out.println("type n,s,e,w to move in a direction");
System.out.println("type stats to see your stats");
System.out.println("type look and then …Run Code Online (Sandbox Code Playgroud)