• 0

Is something wrong with Console Application in Visual Studio C# ?


Question

I've started working with console application for a while some of the programs that executed worked properly and gave the correct output, but some executed properly but no output was displayed in Debugger, here's one of of them

 class Duck : IComparable<Duck>
    {
        public int Size;
        public KindOfDuck Kind;

        public int CompareTo(Duck duckToCompare)
        {
            if (this.Size > duckToCompare.Size)
                return 1;
            else if (this.Size < duckToCompare.Size)
                return -1;
            else
                return 0;
        }
    }
    enum KindOfDuck
    {
        Mallard,
        Muscovy,
        Decoy,
    }
class Program
{
        public static void PrintDucks(List<Duck> ducks)
        {
            foreach (Duck duck in ducks)
                Console.WriteLine(duck.Size.ToString() + "-inch " + duck.Kind.ToString());
            Console.WriteLine("End of ducks!");
        }
        static void Main(string[] args)
        {

            List<Duck> ducks = new List<Duck>()
            {
                new Duck() {Kind = KindOfDuck.Mallard, Size = 17 },
                new Duck() {Kind = KindOfDuck.Muscovy, Size = 18 },
                new Duck() {Kind = KindOfDuck.Decoy, Size = 14 },
                new Duck() {Kind = KindOfDuck.Muscovy, Size = 11 },
                new Duck() {Kind = KindOfDuck.Mallard, Size = 14 },
                new Duck() {Kind = KindOfDuck.Decoy, Size = 13 },
            };
            ducks.Sort();
            Console.ReadKey();
        }
}

When i press the start button, under the output tab its shows symbols loaded, but in the Debug//ConsoleApplication.exe nothing seem to appear it's just blank,

Do i need to  include a  library in the program class so that output is displayed ?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.