New to c#, not new to programming. Actually working on my for project in c# and I have been wanting to write to the console. Everywhere I have looked, System.Console.WriteLine has been the unanimous choice. Here is what I have.
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;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace First_Project
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
public static void Main()
{
Console.WriteLine("Henlo");//These two lines throw the error
System.Console.WriteLine("Henlo");
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
MediaElement mediaElement = new MediaElement();
var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Henlo, Woo-urld!");
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();
}
}
}
It is saying "The name Console does not exist in the current context" and "The namespace Console does not exist in the namespace System" respectively. I am hoping that I am just making a simple mistake but I cannot seem to figure it out on my own. If I have neglected to include any needed information, please let me know.