簡體   English   中英

不返回值的路徑?

[英]path that doesn't return a value?

我正在編寫一個應用程序,該應用程序將根據用戶輸入在平面文件中搜索特定數據,並且此應用程序即將問世。 但是,我一定是個白痴。 我已經通過此方法進行了3次檢查,但沒有看到未返回值的路徑,但是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的一個小故障; 關閉並重新打開該項目即可修復它。 至少我知道這不是我自己的錯誤!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM