[英]C# Error Message: CS1503Argument 1: cannot convert from 'void' to 'bool'
Does anybody can help me with this issue?有人可以帮我解决这个问题吗? I can't run this code on VS.
我无法在 VS 上运行此代码。 It's displaying Cannot convert from "void" to bool.
它显示无法从“void”转换为布尔值。 I got stuck here and I can't run this piece of code.
我被困在这里,我无法运行这段代码。
Any idea about where the issue is?关于问题出在哪里的任何想法?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace HelloWorld
{
class Program
{
static void Main(string[] args, Array array)
{
int[] newAge = { 21, 31, 41, 51, 61 };
int[] olderAge = { 71, 81, 91, 101, 121 };
//int i = newAge.Length;
Console.WriteLine(Array.Copy(newAge, olderAge, 4));
}
}
}
Array.Copy
doesn't return anything. Array.Copy
不返回任何内容。 So there's nothing to write to the console.所以没有什么可写到控制台的。 Simply remove that
Console.WriteLine
operation:只需删除该
Console.WriteLine
操作:
Array.Copy(newAge, olderAge, 4);
Then the question becomes... What do you want to write to the console?那么问题就变成了……你想给控制台写什么? For example, if you want to output the contents of one of the arrays, output that:
例如,如果要 output 的内容之一是 arrays、output 即:
Console.WriteLine(string.Join(',', newAge));
This would join the values from newAge
into a comma-delimited string and write that string to the console.这会将
newAge
中的值连接到逗号分隔的字符串中,并将该字符串写入控制台。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.