using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入字符串:");
Console.ReadLine();
string[] myStr;
char[] separator ={ ' ' };
myStr = Console.ReadLine().ToString().Split(separator);
foreach (string words in myStr)
{
words = words.PadLeft(words.Length+1,'"');
Console.WriteLine("{0}",words);
}
Console.ReadKey();
}
}
}
错误 1 “words”是一个“foreach 迭代变量”,无法为它赋值 D:\temp\ConsoleApplication1\ConsoleApplication1\Program.cs 18 17 ConsoleApplication1
程序是想读取一个输入的字符串,并用空格把他分成单词,并在每个单词左右加上双引号.
我现在解决不了请教哪为达人了.