我如何使用数组从键盘输入一个短语?

How can i enter from keyboard a phrase using an array?

根据我的理解,这是必要的:

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

namespace ConsoleApplication1
{
    class Program
    {
        public const int N = 100;
        static void Main(string[] args)
        {
            char[] phrase = new char[N];
            int i=0;
            Console.WriteLine("enter a phrase: ");
            while ((i < N) && (phrase[i] != '.'))
            {
                phrase[i] = Convert.ToChar(Console.ReadLine());
                i++;
            }
             while(i<N){
                Console.WriteLine(+phrase[i]+"  ");
                i++;
            }
            Console.ReadLine();

        }
    }
}

而且我想知道是否有一种方法可以让我输入一个短语而不必为我介绍的每个字符都按介绍

除非我遗漏了什么,否则你可以这样做:

 static void Main(string[] args)
 {           
        Console.WriteLine("enter a phrase: ");
        string phrase = Console.ReadLine();           
        var chars = phrase.ToCharArray();  //If you want it as a char array
 }

Console.ReadLine() 将读取该行,直到用户点击 return/enter 并且我们可以存储这是字符串短语。如果您确实希望在 char 数组中输入,您可以在字符串

上使用 .ToCharArray() 函数