square

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static void Main()
	{
		Console.WriteLine("Please enter a number:");
		// assuming that the user will put int only, i will not the validation for making things simple
		var number=Convert.ToInt32(Console.ReadLine());
		for(int i=0; i < number; i++)
		{			
			for(int j=0; j < number; j++)
			{			
				if(i==0 || i == number-1 || j==0 || j == number-1)
					Console.Write("* "); // adding * and space to make the horizontal and vertical widths almost the same,
				                         //to know more, try to remove the spaces and let the number = 25, result will be sides not equal in visual display
				else 
					Console.Write("  "); // adding 2 spaces instead of one to let the horizontal and veritcal widths almost the same
			}
			Console.Write("\n");
		}
	}
}
;