c# - 尝试在 C# 中使用数组和 forloop 在 GUI 中创建亵渎过滤器,但 forloop 搞乱了 remove 方法
问题描述
这是我的阵列,
public String[] Swears = new string[22] {"bad words"}
这里面有22个脏话,这里就不放了。这工作得很好,但似乎在 forloop 中不起作用
这是用户输入其姓名的文本框,其中包含一个似乎不起作用的删除语句。当此代码运行时,它只能删除前 4 个脏话,但之后的脏话会导致错误
public void player1Name_TextChanged(object sender, EventArgs e)
{
for(int i =0; i<22; i++)
{
if (player1Name.Text == Swears[i])
{
int o = player1Name.Text.Length;
player1Name.Text = (Swears[i].Remove(4));
MessageBox.Show("please enter a valid Name");
}
}
}
解决方案
推荐阅读
- xaml - IValueConverter – 将对象作为 ConverterParameter 传递
- fork - 子进程上的 valgrind 无法正常工作。10分钟后所有进程都关闭
- php - 如何从 google 客户端 API 获取搜索关键字详细信息
- c# - 聚焦时如何自动打开组合框?
- sql - SQL Server 中层次结构的递归克隆
- javascript - 用动态 react-pose、react 和 redux 改变 div 的位置
- javascript - 以分钟为单位添加时间值并以小时和分钟为单位显示
- xml - 如何使用 Scala 计算 XML 文件中的元素
- sql - SQL Server 语法,同一查询中的多个 SELECT COUNT(columnA) WHERE (columnA=difvalue)
- haproxy - 从 HAProxy 中的 Referer Header 字段中提取参数