Jump to content

I am very new to coding and I am currently learning the language c#. I have been watching the CodeGasm sereis but I keep getting this wrong and I don't why. It would be great if you explain it to me :D 

 

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

//namespace
namespace TylersFirstApp
{   //class (Contains Functionality)
    class Program
    {
        private static object keyInfo;

        //function (Entry Point)
        static void Main(string[] args)
        {
            Console.WriteLine("Type a number, any number");
            ConsoleKeyInfo keyinfo Console.ReadKey();
            ConsoleWriteLine("Did you type {0}", keyInfo.KeyChar.ToString());
        }

 

Link to comment
https://linustechtips.com/topic/660875-what-is-wrong-here/
Share on other sites

Link to post
Share on other sites

It is not whole code, right? Cause there are no closing brackets but I guess it is just a not full paste. But this one is wrong in particular:

ConsoleKeyInfo keyinfo Console.ReadKey();

You miss assign operator so your keyinfo variable can store result of ReadKey method. So it would look like this:

ConsoleKeyInfo keyinfo = Console.ReadKey();

 

Link to comment
https://linustechtips.com/topic/660875-what-is-wrong-here/#findComment-8545060
Share on other sites

Link to post
Share on other sites

1 minute ago, Mr_KoKa said:

It is not whole code, right? Cause there are no closing brackets but I guess it is just a not full paste. But this one is wrong in particular:


ConsoleKeyInfo keyinfo Console.ReadKey();

You miss assign operator so your keyinfo variable can store result of ReadKey method. So it would look like this:


ConsoleKeyInfo keyinfo = Console.ReadKey();

 

Its all the code.

 

Just fixed it though :)

Link to comment
https://linustechtips.com/topic/660875-what-is-wrong-here/#findComment-8545065
Share on other sites

Link to post
Share on other sites

So you are also missing closing bracket of namespace and of class. You see, you need to close every bracket you open. Your indentation is good, so at least it is well visible where closing brackets should be.

namespace TylersFirstApp
{   //class (Contains Functionality)
    class Program
    {
        //...
    }
}

 

Link to comment
https://linustechtips.com/topic/660875-what-is-wrong-here/#findComment-8545082
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×