0
我正在編寫一個應用程序,它將根據用戶輸入搜索特定數據的平面文件,並且它正在出現。但是,我一定是個白癡。我已經檢查了這個方法三次,沒有看到價值沒有返回的路徑,但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]";
}
}
我剛剛在VS 2010編譯你的代碼,並沒有這樣的錯誤。 –
它也不會給我這個錯誤。 VS可以通過誤導性的線路報告錯誤嗎? – TheEvilPenguin
它應該提及一個函數名稱。你確定它是'UserData'嗎? –