+ 1
I cant understand this
Fill in the blanks to ask for user input in the method and return the value entered using output parameters. static void Ask( out string name) { ???? = Console.ReadLine(); } static void Main(string[] args) { string nm; Ask( out nm); } What should be before Console.readline
3 odpowiedzi
+ 3
Note that the Ask method has a return type of void, which means it doesn't actually return a value of any particular type from its method. Here the use of the out keyword is used when passing the argument to the method along with the declaration of the parameter so that the value of the objects address is passed and used within the Ask method so that it may assign the value using the alias 'name' within the Ask method to the nm variable that is passed in as the argument.
static void Main(string[] args)
{
string nm;
Ask(out nm);
Console.WriteLine(nm);
}
static void Ask(out string name) {
name = Console.ReadLine();
}
+ 2
variable declaration
String name ;
name=Console.ReadLine();
or
String name=Console.ReadLine();
you ask the computer to save user input in this variable.
+ 1
thanks a lot