C# 我的C程序有什么问题?

C# 我的C程序有什么问题?,c#,arrays,C#,Arrays,我需要创建一个应用程序,用随机数填充数组。我编写了整个代码,它可以工作,但数字没有显示在控制台窗口中。代码可能有什么问题?谢谢 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Arrays { class Program { static void Main(string[] args) {

我需要创建一个应用程序,用随机数填充数组。我编写了整个代码,它可以工作,但数字没有显示在控制台窗口中。代码可能有什么问题?谢谢

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Arrays
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = new int[10]; 
            Random randomNumbers = new Random();

            for (int i = 0; i < array.Length; i++)
            {
                int randomValue = randomNumbers.Next(0,500);
                array[i] = randomValue;
            }

            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine("The array value is: ", array[i]);
            }
        }
    }
}
你可以使用

Console.WriteLine("The array value is: {0}", array[i]);

但是你写的

Console.WriteLine("The array value is: ", array[i]);
完全没有告诉控制台在何处以及如何使用array[i]变量

Console.WriteLine("The array value is: {0}", array[i]);
您必须在格式字符串中指出您要打印一些值。

您缺少

Console.ReadLine();
在Console.WriteLine之后

正如其他人提到的,要使这一行使用{0},需要将其格式化为字符串

Console.WriteLine(string.Format("The array value is: {0}", array[i]));

Console.WriteLineThe数组值为:{0},数组[i]

谢谢,我很笨。。。我总是怀念那部分。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Coefficient Of x (Positive): ");
            int coef = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter Value Of c: ");
            int c = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("From? (Positive)");
            int from = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("To? (Positive)");
            int to = Convert.ToInt32(Console.ReadLine());
            Console.Clear();
            int[] y_val = new int[(to - from) + 1];
            int counter = 0;
            for (int i = to; i >= from; i--)
            {
                y_val[counter] = ((coef * i) + c);
                counter++;
            }
            int x = 0;
            for (int i = to; i >= from; i--)
            {
                if (y_val[x] == ((coef * i) + c))
                {
                    if (y_val[x] >= 10)
                    {
                        Console.WriteLine("{0}|", y_val[x]);
                    }
                    else
                    {
                        Console.WriteLine("0{0}|", y_val[x]);
                    }
                    for (int j = 0; j < i; j++)
                    {
                        Console.Write("  ");
                    }
                    Console.Write("*");
                    Console.WriteLine();

                }
                x++;
            }
            Console.WriteLine("______________________________________________________________");
            Console.WriteLine("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23");
            Console.ReadKey();
        }
    }
}
Console.WriteLine(string.Format("The array value is: {0}", array[i]));
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Coefficient Of x (Positive): ");
            int coef = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter Value Of c: ");
            int c = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("From? (Positive)");
            int from = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("To? (Positive)");
            int to = Convert.ToInt32(Console.ReadLine());
            Console.Clear();
            int[] y_val = new int[(to - from) + 1];
            int counter = 0;
            for (int i = to; i >= from; i--)
            {
                y_val[counter] = ((coef * i) + c);
                counter++;
            }
            int x = 0;
            for (int i = to; i >= from; i--)
            {
                if (y_val[x] == ((coef * i) + c))
                {
                    if (y_val[x] >= 10)
                    {
                        Console.WriteLine("{0}|", y_val[x]);
                    }
                    else
                    {
                        Console.WriteLine("0{0}|", y_val[x]);
                    }
                    for (int j = 0; j < i; j++)
                    {
                        Console.Write("  ");
                    }
                    Console.Write("*");
                    Console.WriteLine();

                }
                x++;
            }
            Console.WriteLine("______________________________________________________________");
            Console.WriteLine("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23");
            Console.ReadKey();
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication36
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("asd");
        }
    }
}