C# Linq列表的问题

C# Linq列表的问题,c#,linq,C#,Linq,我是Linq的新手,不知道是否有人能帮我。我试着让我的代码在我输入的地方,它会把第一个字母或任何单词改成大写。老师要求我们使用Linq并在最后显示结果 例如,当它说“你的名字是什么”时,假设我输入“mark”或“mark gallows”,它会将其更改为“mark”和“mark gallows”。我希望能够在代码中没有嵌入标记的情况下输入它 static void Main(string[] args) { string firstname; st

我是Linq的新手,不知道是否有人能帮我。我试着让我的代码在我输入的地方,它会把第一个字母或任何单词改成大写。老师要求我们使用Linq并在最后显示结果

例如,当它说“你的名字是什么”时,假设我输入“mark”或“mark gallows”,它会将其更改为“mark”和“mark gallows”。我希望能够在代码中没有嵌入标记的情况下输入它

    static void Main(string[] args)
    {
        string firstname;
        string lastname;
        string street;
        string city;
        string state;
        string zip;
        Console.Write("What is your first name: ");
        firstname= Console.ReadLine();
        Console.Write("What is your last name:");
        lastname= Console.ReadLine();
        Console.Write("What is your street name:");
        street= Console.ReadLine();
        Console.Write("What is your city name:");
        city= Console.ReadLine();
        Console.Write("What is your state name:");
        state= Console.ReadLine();
        Console.Write("What is your zip code:");
        zip= Console.ReadLine();
    }
    public static string UppercaseWords(string value)
    {
        char[] array = value.ToCharArray();
        List<string> items = new List<string>();
        items.Add("firstName"); 
        items.Add("lastName"); 
        items.Add("street"); 
        items.Add("city");
        items.Add("state");
        items.Add("zip");


        var x =
     from item in items
     let UppercaseWords = item.ToCharArray()
     select UppercaseWords;

      foreach (var item in x)
            Console.Write("{0} ", item);
        if (array.Length >= 1)
        {
            if (char.IsLower(array[0]))
            {
                array[0] = char.ToUpper(array[0]);
            }
        }

        for (int i = 1; i < array.Length; i++)
        {
            if (array[i - 1] == ' ')
            {
                if (char.IsLower(array[i]))
                {
                    array[i] = char.ToUpper(array[i]);
                }
            }
        }
        return new string(array);
    }
static void Main(字符串[]args)
{
字符串名;
字符串lastname;
弦街;;
字符串城市;
字符串状态;
拉链;
控制台。写下(“你的名字是什么:”);
firstname=Console.ReadLine();
控制台。写下(“你姓什么:”);
lastname=Console.ReadLine();
控制台。写下(“你的街道名是什么:”);
street=Console.ReadLine();
控制台。写下(“你的城市名是什么:”);
city=Console.ReadLine();
控制台。写下(“你的州名是什么:”);
state=Console.ReadLine();
控制台。写(“你的邮政编码是什么:”);
zip=Console.ReadLine();
}
公共静态字符串大写字(字符串值)
{
char[]数组=value.ToCharArray();
列表项=新列表();
项目。添加(“名字”);
项目。添加(“姓氏”);
项目。添加(“街道”);
项目。添加(“城市”);
项目。添加(“州”);
项目。添加(“zip”);
变量x=
从项目中的项目
让大写字母=item.ToCharArray()
选择大写字母;
foreach(x中的变量项)
写入(“{0}”,项);
如果(array.Length>=1)
{
if(char.IsLower(数组[0]))
{
数组[0]=char.ToUpper(数组[0]);
}
}
for(int i=1;i
输入结果以查看更改后,如何显示结果?

您可以使用:

s = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(s);
您只需使用:

s = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(s);

你不需要林克。这就是你需要的你不需要linq。这就是你需要的也许是重复答案,也许是重复答案。