0

Ok, so I am using C# for the first time and am using Visual Studio. I edited the MainPage.xaml.cs with my simple code and Visual Studio raised an error that The name 'Console' does not exist in the current context. Here is an image of the same:

enter image description here

The code of the file is given below, but I can't understand what's wrong here...

// The `using` statements were pre-given in the original (default) code
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace App1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

Please help me out...

SK-the-Learner
  • 523
  • 5
  • 18
  • Console is for use in console applications. When you created this solution, did you select Console Application? – Nicholas Hunter Apr 05 '21 at 16:04
  • Umm, no, @NicholasHunter As mentioned it's the first time I'm using C#, so I'm sorry for any mistakes... It is actually for a Universal Windows App. Please tell me what I should do... – SK-the-Learner Apr 05 '21 at 16:10
  • check this answer https://stackoverflow.com/questions/44714163/i-cannot-use-debug-print-or-console-writeline-as-i-get-the-error-the-name-co – akb Apr 05 '21 at 16:11
  • You seem to have edited more than just `MainPage.xaml.cs`. Or where is the above `Program` class implemented. Remove it. It makes no sense in a UWP app. – mm8 Apr 06 '21 at 16:05
  • Has your question been solved? If yes, you could post the solution as an answer and mark yourself, which will help others that faces the same question. – dear_vv Apr 20 '21 at 08:09

0 Answers0