gpt4 book ai didi

c# - 如何在 "richTextBox.Lines"数组中将符号编号更改为大写...?

转载 作者:太空宇宙 更新时间:2023-11-03 14:11:54 24 4
gpt4 key购买 nike

如何在“richTextBox.Lines”数组中更改为大写符号编号...?我对“ToUpper()”有疑问,因为它仅适用于“字符串”数据,但我需要根据符号的数量将大小写更改为大写。

例如……我有文字..."qwerty\n asdfgh\n zxcvbn"...在“richTextBox.Text”中,我需要将每行 (e、d、c) 中符号 #3 的大小写更改为大写。

最佳答案

我不知道你的具体情况是什么,但你可以扩展下面的单词代码,......:

我:

var strs = richtextbox.Text.Split("\n".ToCharArray());
var items = "";
foreach(var item in strs)
{
items += new string(item.Select((x,index)=> index == 2?x.ToUpper():x)
.ToArray())
+ "\n";
}

编辑:据我从您的评论中了解到,这对您有用:

indexUpper 是输入例如设置为 3:

二:

richTextBox1.Lines = richTextBox1.Lines
.Where(x => x.Length > indexUpper + 1)
.Select(s => s.Substring(0,indexUpper)
+ s[indexUpper].ToString().ToUpper()
+ s.Substring(indexUpper,s.Length - indexUpper - 1))
.ToArray();

如果你想拥有所有项目:

三:

             this.richTextBox1.Lines = richTextBox1.Lines
//.Where(x => x.Length > indexUpper + 1)
.Select(s => s.Length > indexUpper + 1? s.Substring(0,indexUpper)
+ s[indexUpper].ToString().ToUpper()
+ s.Substring(indexUpper + 1,s.Length - indexUpper - 1)
: s.Length == indexUpper + 1?
s.Substring(0,indexUpper)
+ s[indexUpper].ToString().ToUpper()
:s).ToArray();

关于c# - 如何在 "richTextBox.Lines"数组中将符号编号更改为大写...?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7538279/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com