即使我没有错误,C#代码也没有构建/运行

时间:2017-08-03 04:01:40

标签: c# algorithm visual-studio debugging visual-studio-2015

因为标题显示我的C#代码没有运行/调试,即使我显示0错误。

我开始调试,所有发生的事情是控制台屏幕快速闪烁然后退出0错误。即使bin \ debug文件夹中的.exe也完全相同。我收到的只是输出部分的一面文字墙。

  

Algorithms.vshost.exe'(CLR v4.0.30319:Algorithms.vshost.exe):已加载C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll。符号已加载。

     

线程0x12b8退出了代码0 (0x0)

     

线程0x289c退出了代码0 (0x0)

     

程序[15012] Algorithms.vshost.exe已退出代码0 (0x0)

我希望这是可以理解的!我要感谢任何帮助,谢谢!

一些人要求的代码!我希望它有用!到目前为止,我很感谢所有答案和帮助!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AlgorithmsResit
{
class Program
{
    private static void Main(string[] args)
    { }


    public static void AlgorithmSortInt(int[] array)
    {
        int j = array.Length - 1;
        int x, i, temp;

        for (x = 1; x <= j; ++x)
        {
            temp = array[x];
            for (i = x - 1; i >= 0; --i)
            {
                if (temp < array[i]) array[i + 1] = array[i];
                else break;
            }
            array[1 + 1] = temp;
        }

    }

    public static void AlgorithmSortDouble(double[] array)
    {
        int j = array.Length - 1;
        int x, i;
        double temp;

        for (x = 1; x <= j; ++x)
        {
            temp = array[x];
            for (i = x - 1; i >= 0; --i)
            {
                if (temp < array[i]) array[i + 1] = array[i];
                else break;
            }
            array[i + 1] = temp;
        }

    }
    public static void AlgorithmDateTime(DateTime[] array)
    {
        int j = array.Length - 1;
        int x, i;
        DateTime temp;

        for (x = 1; x <= j; ++x)
        {
            temp = array[x];
            for (i = x - 1; i >= 0; --i)
            {
                if (temp < array[i]) array[i + 1] = array[i];
                else break;
            }
            array[i + 1] = temp;
        }
    }

    public static void StringToSort(string[] array)
    {
        int x = array.Length - 1;

        for (int j = 0; j < x; j++)
        {
            for (int i = x; i > j; i--)
            {
                if (((IComparable)array[i - 1]).CompareTo(array[i]) > 0)
                {
                    var temp = array[i - 1];
                    array[i - 1] = array[i];
                    array[i] = temp;
                }
            }
        }
    }

    static void main(string[] args)
    {
        string[] Day1 = System.IO.File.ReadAllLines(@"TextFiles/Day_1.txt");
        List<int> Day1List = new List<int>();
        foreach (string Day in Day1)
        {
            int Days = Convert.ToInt32(Day);
            Day1List.Add(Days);
        }
        int[] Day1Arr = Day1List.ToArray();


        string[] Depth1 = System.IO.File.ReadAllLines(@"TextFiles/Depth_1.txt");
        List<double> Depth1List = new List<double>();
        foreach (string Depth in Depth1)
        {
            double Depths = Convert.ToDouble(Depth);
            Depth1List.Add(Depths);
        }
        double[] Depth1Arr = Depth1List.ToArray();


        string[] IRISID1 = System.IO.File.ReadAllLines(@"TextFiles/IRIS_ID_1.txt");
        List<int> Iris1List = new List<int>();
        foreach (string IRIS in IRISID1)
        {
            int Iris = Convert.ToInt32(IRIS);
            Iris1List.Add(Iris);
        }
        int[] Iris1Arr = Iris1List.ToArray();


        string[] Latitude1 = System.IO.File.ReadAllLines(@"TextFiles/Latitude_1.txt");
        List<double> Latitude1List = new List<double>();
        foreach (string Lat in Latitude1)
        {
            double Latitude = Convert.ToDouble(Latitude1);
            Latitude1List.Add(Latitude);
        }
        double[] Latitude1Arr = Latitude1List.ToArray();


        string[] Longitude1 = System.IO.File.ReadAllLines(@"TextFiles/Longitude_1.txt");
        List<double> Longitude1List = new List<double>();
        foreach (string Longitude in Longitude1)
        {
            double Longitudes = Convert.ToDouble(Longitude1);
            Longitude1List.Add(Longitudes);
        }
        double[] Longitude1Arr = Longitude1List.ToArray();


        string[] Magnitude1 = System.IO.File.ReadAllLines(@"TextFiles/Magnitude_1.txt");
        List<Double> Magnitude1List = new List<Double>();
        foreach (string Magnitude in Magnitude1)
        {
            double Magnitudes = Convert.ToDouble(Magnitude1);
            Magnitude1List.Add(Magnitudes);
        }
        double[] Magnitude1Arr = Magnitude1List.ToArray();

        string[] Month1 = System.IO.File.ReadAllLines(@"TextFiles/Month_1.txt");

        string[] Region1 = System.IO.File.ReadAllLines(@"TextFiles/Region_1.txt");


        string[] Time1 = System.IO.File.ReadAllLines(@"TextFiles/Time_1.txt");
        List<DateTime> Time1List = new List<DateTime>();
        foreach (string Time in Time1)
        {
            DateTime Times = Convert.ToDateTime(Time);
            Time1List.Add(Times);
        }
        DateTime[] Time1Arr = Time1List.ToArray();

        string[] Timestamp1 = System.IO.File.ReadAllLines(@"TextFiles/Timestamp_1.txt");
        List<int> Timestamp1List = new List<int>();
        foreach (string Timestamp in Timestamp1)
        {
            int Timestamps = Convert.ToInt32(Timestamp);
            Timestamp1List.Add(Timestamps);
        }
        int[] Timestamp1Arr = Timestamp1List.ToArray();


        string[] Year1 = System.IO.File.ReadAllLines(@"TextFiles/Year_1.txt");
        List<int> Year1List = new List<int>();
        foreach (String Date in Year1)
        {
            int Dates = Convert.ToInt32(Date);
            Year1List.Add(Dates);
        }
        int[] Year1Arr = Year1List.ToArray();

        string UserArrayChoice, AscOrDescChoice;
        int ArrayChoice;

        int count = 0;
        do
        {
            count++;
            Console.Write("{0} ", Day1Arr[count]);
            Console.Write("{0} ", Depth1[count]);
            Console.Write("{0} ", IRISID1[count]);
            Console.Write("{0} ", Latitude1Arr[count]);
            Console.Write("{0} ", Longitude1Arr[count]);
            Console.Write("{0} ", Magnitude1Arr[count]);
            Console.Write("{0} ", Month1[count]);
            Console.Write("{0} ", Region1[count]);
            Console.Write("{0} ", Time1Arr[count]);
            Console.Write("{0} ", Timestamp1Arr[count]);
            Console.Write("{0}", Year1Arr[count]);
            Console.Write("\n");
        } while (count < Year1Arr.Length - 1);

        Console.WriteLine("Enter the number of the file you would like to sort... \n1 ) Day_1.txt\n2 ) Depth_1.txt\n3 ) IRIS_ID_.txt\n4 ) Latitude_1.txt\n5 ) Longitude_1.txt\n6 ) Magnitude_1.txt\n7 ) Month_1.txt\n8 ) Region_1.txt\n9 ) Time_1.txt\n10 ) Timestamp_1.txt\n11 ) Year_1.txt\n12");
        UserArrayChoice = Console.ReadLine();
        ArrayChoice = Convert.ToInt32(UserArrayChoice);

        switch (UserArrayChoice)
        {
            case "1":
                UserArrayChoice = "Day_1.txt";
                break;
            case "2":
                UserArrayChoice = "Depth_1.txt";
                break;
            case "3":
                UserArrayChoice = "IRIS_ID_1.txt";
                break;
            case "4":
                UserArrayChoice = "Latitude_1.txt";
                break;
            case "5":
                UserArrayChoice = "Longitude_1.txt";
                break;
            case "6":
                UserArrayChoice = "Magnitude_1.txt";
                break;
            case "7":
                UserArrayChoice = "Month_1.txt";
                break;
            case "8":
                UserArrayChoice = "Region_1.txt";
                break;
            case "9":
                UserArrayChoice = "Time_1.txt";
                break;
            case "10":
                UserArrayChoice = "Timestamp_1.txt";
                break;
            case "11":
                UserArrayChoice = "Year_1.txt";
                break;
            default:
                break;
        }
        Console.WriteLine("---------------------------------------------------------------------------");
        Console.WriteLine("{0} Has been selected, would you like to sort by Ascending or Descending?  ", UserArrayChoice);
        Console.WriteLine("---------------------------------------------------------------------------");
        AscOrDescChoice = Console.ReadLine();

        if (AscOrDescChoice == "Ascending" | AscOrDescChoice == "ascending")
        {
            Console.WriteLine("---------------------------------");
            Console.WriteLine("{0} Will sort in Ascending order!", UserArrayChoice);
            Console.WriteLine("---------------------------------");
            switch (ArrayChoice)
            {
                case 1:
                    AlgorithmSortInt(Day1Arr);
                    foreach (int temp in Day1Arr)
                    {
                        Console.WriteLine("{0} ", temp);
                    }
                    break;

                case 2:
                    AlgorithmSortDouble(Depth1Arr);
                    foreach (double temp in Depth1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;
                case 3:
                    AlgorithmSortInt(Iris1Arr);
                    foreach (int temp in Iris1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 4:
                    AlgorithmSortDouble(Latitude1Arr);
                    foreach (double temp in Latitude1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 5:
                    AlgorithmSortDouble(Longitude1Arr);
                    foreach (double temp in Longitude1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 6:
                    AlgorithmSortDouble(Magnitude1Arr);
                    foreach (double temp in Magnitude1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 7:
                    StringToSort(Month1);
                    foreach (string temp in Month1)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 8:
                    StringToSort(Region1);
                    foreach (string temp in Region1)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 9:
                    AlgorithmDateTime(Time1Arr);
                    foreach (DateTime temp in Time1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 10:
                    AlgorithmSortInt(Timestamp1Arr);
                    foreach (int temp in Timestamp1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 11:
                    AlgorithmSortInt(Year1Arr);
                    foreach (int temp in Year1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

            }
        }

        else if (AscOrDescChoice == "Descending" | AscOrDescChoice == "descending")
        {
            Console.WriteLine("----------------------------------");
            Console.WriteLine("{0} Will sort in Descending order!", UserArrayChoice);
            Console.WriteLine("----------------------------------");

            switch (ArrayChoice)

            {
                case 1:
                    AlgorithmSortInt(Day1Arr);
                    Array.Reverse(Day1Arr);
                    foreach (int temp in Day1Arr)
                    {
                        Console.WriteLine("{0} ", temp);
                    }
                    break;

                case 2:
                    AlgorithmSortDouble(Depth1Arr);
                    Array.Reverse(Depth1Arr);
                    foreach (double temp in Depth1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;
                case 3:
                    AlgorithmSortInt(Iris1Arr);
                    Array.Reverse(Iris1Arr);
                    foreach (int temp in Iris1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 4:
                    AlgorithmSortDouble(Latitude1Arr);
                    Array.Reverse(Latitude1Arr);
                    foreach (double temp in Latitude1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 5:
                    AlgorithmSortDouble(Longitude1Arr);
                    Array.Reverse(Longitude1Arr);
                    foreach (double temp in Longitude1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 6:
                    AlgorithmSortDouble(Magnitude1Arr);
                    Array.Reverse(Magnitude1Arr);
                    foreach (double temp in Magnitude1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 7:
                    StringToSort(Month1);
                    Array.Reverse(Month1);
                    foreach (string temp in Month1)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 8:
                    StringToSort(Region1);
                    Array.Reverse(Region1);
                    foreach (string temp in Region1)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 9:
                    AlgorithmDateTime(Time1Arr);
                    Array.Reverse(Time1Arr);
                    foreach (DateTime temp in Time1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 10:
                    AlgorithmSortInt(Timestamp1Arr);
                    Array.Reverse(Timestamp1Arr);
                    foreach (int temp in Timestamp1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

                case 11:
                    AlgorithmSortInt(Year1Arr);
                    Array.Reverse(Year1Arr);
                    foreach (int temp in Year1Arr)
                    {
                        Console.WriteLine("{0}", temp);
                    }
                    break;

            }
        }
        else
        {
            Console.WriteLine("-------------------");
            Console.WriteLine("Incorrect Response!");
            Console.WriteLine("-------------------");
        }

        Console.WriteLine("Enter the number of the file you would like to search... \n1 ) Day_1.txt\n2 ) Depth_1.txt\n3 ) IRIS_ID_1\n4 ) Latitude_1\n5 ) Longitude_1\n6 ) Magnitude_1\n7 ) Month_1\n8 ) Region_1\n9 ) Time_1\n10 ) Timestamp_1\n11 ) Year_1\n12");
        UserArrayChoice = Console.ReadLine();
        ArrayChoice = Convert.ToInt32(UserArrayChoice);

        switch (UserArrayChoice)
        {
            case "1":
                UserArrayChoice = "Day_1.txt";
                break;

            case "2":
                UserArrayChoice = "Depth_1.txt";
                break;

            case "3":
                UserArrayChoice = "IRIS_ID_1.txt";
                break;

            case "4":
                UserArrayChoice = "Latitude_1.txt";
                break;

            case "5":
                UserArrayChoice = "Longitude_1.txt";
                break;

            case "6":
                UserArrayChoice = "Magnitude_1.txt";
                break;

            case "7":
                UserArrayChoice = "Month_1.txt";
                break;

            case "8":
                UserArrayChoice = "Region_1.txt";
                break;

            case "9":
                UserArrayChoice = "Time_1.txt";
                break;

            case "10":
                UserArrayChoice = "Timestamp_1.txt";
                break;

            case "11":
                UserArrayChoice = "Year_1.txt";
                break;
            default:
                break;
        }

        Console.WriteLine("--------------------------------------------------------------------");
        Console.WriteLine("{0} has been selected! Please enter what you would like to search - ", UserArrayChoice);
        Console.WriteLine("--------------------------------------------------------------------");
        string SearchTemp = Console.ReadLine();
        bool Found = false;
        int counter = 0;

        switch (ArrayChoice)
        {
            case 1:
                int SearchDay = Convert.ToInt32(SearchTemp);
                for (int x = 0; x < Day1Arr.Length; x++)
                {
                    if (SearchDay == Day1Arr[x])
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 2:
                double DepthSearch = Convert.ToDouble(SearchTemp);
                for (int x = 0; x < Depth1Arr.Length; x++)
                {
                    if (DepthSearch == Depth1Arr[x])
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful!:-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 3:
                int SearchIris = Convert.ToInt32(SearchTemp);
                for (int x = 0; x < Iris1Arr.Length; x++)
                {
                    if (SearchIris == Iris1Arr[x])
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 4:
                double SearchLatitude = Convert.ToDouble(SearchTemp);
                for (int x = 0; x < Latitude1Arr.Length; x++)
                {
                    if (SearchLatitude == Latitude1Arr[x])
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 5:
                double SearchLong = Convert.ToDouble(SearchTemp);
                for (int x = 0; x < Longitude1Arr.Length; x++)
                {
                    if (SearchLong == Longitude1Arr[x])
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 6:
                double SearchMag = Convert.ToDouble(SearchTemp);
                for (int x = 0; x < Magnitude1Arr.Length; x++)
                {
                    if (SearchMag == Magnitude1Arr[x])
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 7:
                foreach (var Months in Month1)
                {
                    if (Months.Contains(SearchTemp))
                    {
                        count++;
                        Found = true;
                        Console.Write("{0} ", Day1Arr[counter]);
                        Console.Write("{0} ", Depth1Arr[counter]);
                        Console.Write("{0} ", Iris1Arr[counter]);
                        Console.Write("{0} ", Latitude1Arr[counter]);
                        Console.Write("{0} ", Longitude1Arr[counter]);
                        Console.Write("{0} ", Magnitude1Arr[counter]);
                        Console.Write("{0} ", Month1[counter]);
                        Console.Write("{0} ", Region1[counter]);
                        Console.Write("{0} ", Time1Arr[counter]);
                        Console.Write("{0} ", Timestamp1Arr[counter]);
                        Console.Write("{0} ", Year1Arr[counter]);
                        Console.Write("\n");
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 8:
                foreach (var Regions in Region1)
                {
                    if (Regions.Contains(SearchTemp))
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 9:
                DateTime SearchDate = Convert.ToDateTime(SearchTemp);
                for (int x = 0; x < Time1Arr.Length; x++)
                {
                    if (SearchDate == Time1Arr[x])
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 10:
                int SearchTimestamp = Convert.ToInt32(SearchTemp);
                for (int x = 0; x < Timestamp1Arr.Length; x++)
                {
                    if (SearchTimestamp == Timestamp1Arr[x])
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

            case 11:
                int SearchYear = Convert.ToInt32(SearchTemp);
                for (int x = 0; x < Year1Arr.Length; x++)
                {
                    {
                        Found = true;
                    }
                }
                if (Found == true) { Console.WriteLine("Successful! :-)"); }
                else { Console.WriteLine("Unsuccessful! Sorry :-("); }
                break;

        }
    }
 }
 }

1 个答案:

答案 0 :(得分:1)

我所知道的只是调试消息。您可以通过右键单击输出窗口并取消选中线程结束消息来关闭它。

http://msdn.microsoft.com/en-us/library/bs4c1wda.aspx

(1)请在您的应用中添加断点,然后再次调试。

喜欢这个帖子: Keeping console window open when debugging

(2)如果您使用“start without debugging”运行它,它将不会关闭。你也可以在你的应用程序中添加Console.ReadLine(),就像这个帖子一样。

(3)如果您只调试应用程序并收到此消息,请同时启用Debugger-&gt; Windows菜单下的例外设置,并确保没有异常。