Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active April 21, 2025 11:38
Show Gist options
  • Select an option

  • Save Strelok78/1941a9771fdebb22dc89bcf76a1f5ea5 to your computer and use it in GitHub Desktop.

Select an option

Save Strelok78/1941a9771fdebb22dc89bcf76a1f5ea5 to your computer and use it in GitHub Desktop.
get symbol and name and return name in square of symbols
using System.Diagnostics;
namespace iJuniorPractice;
class Program
{
static void Main(string[] args)
{
string name;
char symbol;
string symbolLine = "";
string nameLine = "";
string enterSymbolMessage = "Enter symbol: ";
string enterNameMessage = "Enter name: ";
string enterErrorMessage = "Error: enter only one char.";
string result;
Console.Write(enterNameMessage);
name = Console.ReadLine();
Console.Write(enterSymbolMessage);
while (char.TryParse(Console.ReadLine(), out symbol) == false)
{
Console.WriteLine(enterErrorMessage);
}
nameLine = symbol + name + symbol;
for (int i = 0; i < nameLine.Length; i++)
{
symbolLine += symbol;
}
result = symbolLine + "\n" + nameLine + "\n" + symbolLine;
Console.WriteLine(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment