索引超出数组界限,求助!!
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication26
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string cw; string wc;
public void button1_Click(object sender, EventArgs e)
{
readtextfromfile();
}
void readtextfromfile()
{
OpenFileDialog o = new OpenFileDialog();
if (o.ShowDialog() == DialogResult.OK)
{
string file = o.FileName;
string ext = file.Substring(file.LastIndexOf("."));
if (ext.ToLower() != ".txt")
{
MessageBox.Show("bushiwenjian");
return;
}
else
{
richTextBox1.Text = File.ReadAllText(o.FileName, Encoding.Default);
}
}
this.cw = richTextBox1.Text;
}
private void richTextBox2_TextChanged(object sender, EventArgs e)
{
int start = richTextBox2.SelectionStart;
int m = richTextBox1.TextLength > richTextBox2.TextLength ? richTextBox2.TextLength : richTextBox1.TextLength;
for (int i = 0; i < m; i++)
{
if (richTextBox1.Text[i] != richTextBox2.Text[i])
{
richTextBox2.Select(i, 1);
richTextBox2.SelectionColor = Color.Red;
}
}
if (richTextBox2.TextLength > richTextBox1.TextLength)
{
richTextBox2.Select(richTextBox1.TextLength, richTextBox2.TextLength - richTextBox1.TextLength);
richTextBox2.SelectionColor = Color.Red;
}
richTextBox2.SelectionStart = start;
richTextBox2.SelectionColor = richTextBox1.ForeColor;
}
private void button2_Click(object sender, EventArgs e)
{
richTextBox2.SelectAll();
this.wc = richTextBox2.Text;
string[] cc; string[] ww;
cc = cw.Split(' ', '.', ',');
ww = wc.Split(' ', '.', ',');
int j = 0; double t;
for (int i = 0; i < 10; i++)
{
bool result;result = Equals(cc[i], ww[i]);
if (result==true)
{
j++;
}
}
t = (double)j / 10;
string tText = t.ToString("0.0%");
label1.Text = tText;
}
}
}


using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication26
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string cw; string wc;
public void button1_Click(object sender, EventArgs e)
{
readtextfromfile();
}
void readtextfromfile()
{
OpenFileDialog o = new OpenFileDialog();
if (o.ShowDialog() == DialogResult.OK)
{
string file = o.FileName;
string ext = file.Substring(file.LastIndexOf("."));
if (ext.ToLower() != ".txt")
{
MessageBox.Show("bushiwenjian");
return;
}
else
{
richTextBox1.Text = File.ReadAllText(o.FileName, Encoding.Default);
}
}
this.cw = richTextBox1.Text;
}
private void richTextBox2_TextChanged(object sender, EventArgs e)
{
int start = richTextBox2.SelectionStart;
int m = richTextBox1.TextLength > richTextBox2.TextLength ? richTextBox2.TextLength : richTextBox1.TextLength;
for (int i = 0; i < m; i++)
{
if (richTextBox1.Text[i] != richTextBox2.Text[i])
{
richTextBox2.Select(i, 1);
richTextBox2.SelectionColor = Color.Red;
}
}
if (richTextBox2.TextLength > richTextBox1.TextLength)
{
richTextBox2.Select(richTextBox1.TextLength, richTextBox2.TextLength - richTextBox1.TextLength);
richTextBox2.SelectionColor = Color.Red;
}
richTextBox2.SelectionStart = start;
richTextBox2.SelectionColor = richTextBox1.ForeColor;
}
private void button2_Click(object sender, EventArgs e)
{
richTextBox2.SelectAll();
this.wc = richTextBox2.Text;
string[] cc; string[] ww;
cc = cw.Split(' ', '.', ',');
ww = wc.Split(' ', '.', ',');
int j = 0; double t;
for (int i = 0; i < 10; i++)
{
bool result;result = Equals(cc[i], ww[i]);
if (result==true)
{
j++;
}
}
t = (double)j / 10;
string tText = t.ToString("0.0%");
label1.Text = tText;
}
}
}
红色部分运行出现索引超出数组界限

...全文
相关推荐
关于C#索引超出了数组界限的问题??
当此程序调试后点击下拉菜单选项时就会提示索引超出了数组界限,但我找了半天也没有找出错误,请高手帮忙。本人初学,望帮忙修改一下!不胜感激!
ThoughtWorks.QRCode 1.0.4374.31614版本,可解决“索引超出了数组界限”问题
二维码生成dll,ThoughtWorks.QRCode 1.0.4374.31614版本,可解决“索引超出了数组界限”问题
Java中的索引超出界限错误。
ProfilerServant profilerServant = new ProfilerServant(args [4],args [5] .equals(“ true”));您确定args具有6个元素吗?
labview中的数组索引详细讲解
labview中的数组索引详细讲解,写的挺详细的,应该能解决你关于这个问题的困惑
Android应用因索引超出范围问题而崩溃。 请帮我解决这个问题
Android仍基于Java语言,因此例外通常是应用程序中以Java为主题的问题。 “索引超出范围”表示您正在尝试引用当前集合内不可用的元素。 看看异常本身,索引...


