我正在编写一个应用程序,它将根据用户输入在平面文件中搜索特定数据,并且它正在出现。但是,我一定是个白痴。我已经通过这种方法检查了三次并且没有看到没有返回值的路径,但VS 2010 Express向我保证有一个。
我到底错过了什么?提前谢谢。
private string UserData(string[] userDB, bool forEnrollment){
if (nameButton.Checked)
{
if (personBox.Text.Split(' ').Length != 2)
{
WriteDebug("ERROR: Invalid user input");
return null;
}
else
{
List<string> namesFound = new List<string>(); //list of matches for the current person
string parsedFirst = personBox.Text.Split(' ')[0];
string parsedLast = personBox.Text.Split(' ')[1];
string dataSourceKey = null;
WriteDebug("Searching for '" + parsedFirst + " " + parsedLast + "'...");
for (int d = 12; d < userDB.Length - 11; d = d + 10) //search the flat file for matches
{
string dbFirst = GetThree(userDB[d]); //first three characters of FIRST name of current record
string dbLast = GetThree(userDB[d + 1]); //first three characters of LAST name of current record
if (GetThree(parsedFirst) == dbFirst && GetThree(parsedLast) == dbLast) //if the name from the list is similar to the record
{
WriteDebug("Match found while comparing '" + parsedFirst + " " + parsedLast + "' to '" + userDB[d] + " " + userDB[d + 1] + "' (" + userDB[d - 1] + ")");
namesFound.Add(userDB[d - 1] + ": " + userDB[d] + " " + userDB[d + 1]); //add the person to the list of matches
userKey = userDB[d - 1];
dataSourceKey = "\t" + userDB[d + 6];
}
}
if (namesFound.Count == 0) //if no matches are found, write an error line
{
userKey = "ERROR: No matches found for '" + parsedFirst + " " + parsedLast + "'";
WriteDebug("ERROR: No matches found for '" + parsedLast + " " + parsedLast + "'");
return "[ERROR]";
}
else if (namesFound.Count == 1) //if a single match is found, add the record
{
if (forEnrollment) {
return userKey;
}
return userKey + dataSourceKey;
}
else
{
WriteDebug("ERROR: Multiple matches found for '" + parsedFirst + " " + parsedLast + "'");
/*TODO
* add instance of ConflictBox and populate it with namesFound
* prompt user to select one of the matches or skip the record entirely
*/
return "[ERROR]";
}
}
}
else
{
/*TODO
* search for the student id
*
*/
return "[UNFINISHED CODE]";
}
}
答案 0 :(得分:0)
似乎是VS 2010的一个小故障;关闭并重新开放项目修复它。至少我知道这不是我自己的错误!