C# C# Basics Methods Defining a Method

Troy Noseworthy
Troy Noseworthy
201 Points

How can I get each letter to print on a separate line?

It compiles and returns the full word "cat" but not each letter on a separate line.

Program.cs
using System;

class Program
{
    static void Spell()
    {
        Console.Write("c");
    Console.Write("a");
    Console.Write("t");
    }

    static void Main(string[] args)
    {
        Spell();


    }
}

3 Answers

Kevin Gates
Kevin Gates
14,732 Points

Add a newline character: "\n" sometimes it's return and newline like "\r\n" Also, this: https://docs.microsoft.com/en-us/dotnet/api/system.environment.newline?view=netcore-3.0

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,188 Points

Or you could use Console.Writeline as specified in the challenge

Troy Noseworthy
Troy Noseworthy
201 Points

error CS0117: 'Console' does not contain a definition for 'Writeline' [/workdir/workspace.csproj] <-- hence Console.Write.

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,188 Points

My bad it should be WriteLine with a capital L