在C#中下面的一段代码每一行各是什么意思,有什么作用?麻烦讲一下,谢谢
publicclassFileManipulate{//publicstringFileStrings{get;set;}publicfloatStartX{get;se...
public class FileManipulate
{
//public string FileStrings { get; set; }
public float StartX { get; set; }
public float StartY { get; set; }
public float Step { get; set; }
public int SumRow { get; set; }
public int SumColumn { get; set; }
public float[,] XyMatrix { get; set; }
public bool Ready { get; set; }
public void ReadFile()
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "文本文件(*.txt)|*.txt|(*.rtf)|*.rtf";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamReader myReader = new StreamReader(openFileDialog1.FileName, Encoding.Default);
StartX = Convert.ToSingle(myReader.ReadLine().Split(':')[1].Trim());
StartY = Convert.ToSingle(myReader.ReadLine().Split(':')[1].Trim());
Step = Convert.ToSingle(myReader.ReadLine().Split(':')[1].Trim());
SumRow = Convert.ToInt32(myReader.ReadLine().Split(':')[1].Trim());
SumColumn = Convert.ToInt32(myReader.ReadLine().Split(':')[1].Trim());
XyMatrix = new float[SumRow, SumColumn];
string[] exchangeString;
for (int j = 0; j < SumRow; j++)
{
exchangeString = myReader.ReadLine().Split(',');
for (int i = 0; i < SumColumn; i++)
{
XyMatrix[j, i] = Convert.ToSingle(exchangeString[i].Trim());
}
}
myReader.Close();
}
} 展开
{
//public string FileStrings { get; set; }
public float StartX { get; set; }
public float StartY { get; set; }
public float Step { get; set; }
public int SumRow { get; set; }
public int SumColumn { get; set; }
public float[,] XyMatrix { get; set; }
public bool Ready { get; set; }
public void ReadFile()
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "文本文件(*.txt)|*.txt|(*.rtf)|*.rtf";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamReader myReader = new StreamReader(openFileDialog1.FileName, Encoding.Default);
StartX = Convert.ToSingle(myReader.ReadLine().Split(':')[1].Trim());
StartY = Convert.ToSingle(myReader.ReadLine().Split(':')[1].Trim());
Step = Convert.ToSingle(myReader.ReadLine().Split(':')[1].Trim());
SumRow = Convert.ToInt32(myReader.ReadLine().Split(':')[1].Trim());
SumColumn = Convert.ToInt32(myReader.ReadLine().Split(':')[1].Trim());
XyMatrix = new float[SumRow, SumColumn];
string[] exchangeString;
for (int j = 0; j < SumRow; j++)
{
exchangeString = myReader.ReadLine().Split(',');
for (int i = 0; i < SumColumn; i++)
{
XyMatrix[j, i] = Convert.ToSingle(exchangeString[i].Trim());
}
}
myReader.Close();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询