-3
안녕하세요. 문제는 아래 주석에서 확인할 수 있습니다. 기본적으로 내가 입력이 잘못된 형식으로되어 지점에 오는하고 아래도 내가 넣어 시도하고있는 데이터 이유, 내가 볼 수 없습니다.입력 문자열의 형식이 올바르지 않습니다.
데이터를
128,119,137,140,128,117,197 -0.5,0.0,0.5
125,129,136,130,125,162,125 -1.0,0.0,1.0
138,139,135,120,127,117,118 -0.5,0.0,0.5
127,149,138,160,122,217,137
149,129,140,140,129,127,126
153,159,130,140,127,112,126
147,129,130,148,128,137,134
은 사람이 볼 수 왜 그것을 받아들이지 않을까요? 데이터 인 경우
TextReader tr = new StreamReader("c:/users/tom/documents/visual studio 2010/Projects/Exam/Exam/Data.txt");
for (var i = 0; i < 2; i++) // Ignores first two lines
{
String input = tr.ReadLine();
}
string remainingText = tr.ReadToEnd(); //Reads remained
string result = Regex.Replace(remainingText, @"\s+", ",");
char[] delimiterChars = {','}; //Establishes what should split the strings
string[] itemlist = (result.Split(delimiterChars)); //Splits the strings and puts them into itemlist
double[] values = new double[itemlist.Length]; //Creates an array the same size as itemlist
for (int i = 0; i < itemlist.Length; i++)
{
values[i] = (Convert.ToDouble(itemlist[i]));
//Attempts to convert the >values from itemlist into values ERROR, input string not in correct format
}
에
StringSplitOptions.RemoveEmptyEntries
을 추가 하시겠습니까? –이 파일을 어디에서 읽으 셨는지 설명해주십시오.? 컴퓨터의 서버 또는 로컬 파일 경로 ..? – MethodMan
해당 데이터를 게시물에 편집하십시오. – Blorgbeard