C# Challenge: Format English and Russian Console Output

 


Complete the challenge

Code challenges reinforce what you learned and build confidence. In this task, you’ll print clear instructions that tell users where your app writes data files. You’re not creating files yet—just formatting console output for approval.
You’ll apply character escape sequences, verbatim strings, Unicode, and string interpolation to display instructions in both English and Russian.

Challenge: Format and display instructions

Start with the two required lines below. You must not change them, but you may add code above or below. Use only Console.WriteLine() or Console.Write() twice total; any extra spacing or new lines must come from escape sequences, verbatim strings, or interpolation.
string projectName = "ACME";

string russianMessage = "\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0432\u044b\u0432\u043e\u0434";


Goal output

Your code must produce exactly this:
View English output:
  c:\Exercise\ACME\data.txt

Посмотреть русский вывод:
  c:\Exercise\ACME\ru-RU\data.txt


Hints

• Use \n for new lines and spaces or \t for indentation.
• Use @ verbatim strings for Windows paths without escaping backslashes.
• Use $ interpolation to insert projectName and reuse fragments cleanly.
• The provided russianMessage is already Unicode; print it as‑is.

One possible solution (exactly two writes)

string projectName = "ACME";

string russianMessage = "\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0432\u044b\u0432\u043e\u0434";


// 1) English section (title + path) with new lines and indentation
Console.WriteLine(
$"View English output:\n  " +  // label + indent
$@"c:\Exercise\{projectName}\data.txt" + // verbatim + interpolation
"\n" // blank line between sections
);


// 2) Russian section (Unicode label + path)
Console.Write(
$"{russianMessage}:\n  " +    // existing Unicode message + colon + newline + indent
$@"c:\Exercise\{projectName}\ru-RU\data.txt"
);


Why this works

• Only two outputs are used: one WriteLine for the English block and one Write for the Russian block.
• Interpolation inserts {projectName} in both paths.
• Verbatim strings (@"") keep backslashes unescaped in Windows paths.
• Escapes (\n) create the required spacing and blank line.
• Unicode is preserved via russianMessage.

Recap

• Use escapes for layout, verbatim strings for file paths, Unicode for multilingual text, and interpolation for clean templates.
• Reduce extra variables and minimize the number of write calls by composing strings strategically.

Compare your result with the explained challenge solution or revisit the Module 4 guide.

Test your challenge solution

Does displaying the path create data.txt?

No. Console output only displays the instruction. Creating a directory or writing a file requires separate file-system operations, which this exercise does not perform.

Practice and check

Check three things independently: the required variables remain unchanged, exactly two console write calls are used, and the displayed text matches the target. A visually similar result can still contain an extra blank line or missing backslash.

Comments

Popular posts from this blog

C# Student Grades: Format Console Output

C# Console Challenge Solution: Write vs WriteLine

C# String Formatting Challenge: Solution Explained