Tim*_*des 0 .net c# arrays string console-application
我确信我遗失了一些愚蠢的东西.我想将消息打印到控制台窗口,并在同一行显示最大数组值.
当我在没有控制台消息的情况下运行代码时,它运行完美,但是当我使用消息运行代码时,它只显示消息而没有最大值.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Arrays
{
class Program
{
static void Main(string[] args)
{
int[] newArray = new int[6];
newArray[0] = 0;
newArray[1] = 1;
newArray[2] = 2;
newArray[3] = 49;
newArray[4] = 3;
newArray[5] = 82;
Console.Write("The highest number in the array is: ", newArray.Max());
Console.ReadLine();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我刚刚开始掌握数组,但我无法找到解决上述问题的方法.
试试这个
Console.Write("The highest number in the array is: {0} ", newArray.Max());
Run Code Online (Sandbox Code Playgroud)
你可以在这里阅读更多关于string.format的内容:为什么要使用String.Format?