CSharp examples for Language Basics:for
Use a pair of nested loops to create an X pattern
using System;/*from w w w . j av a2s . co m*/ public class Program { public static void Main(string[] args) { int consoleWidth = 40; for(int rowNum = 0;rowNum < consoleWidth;rowNum += 2) { for (int columnNum = 0; columnNum < consoleWidth; columnNum++) { char c = ' '; if (columnNum == rowNum) { c = '\\'; } int mirrorColumn = consoleWidth - rowNum; if (columnNum == mirrorColumn) { c = '/'; } Console.Write(c); } Console.WriteLine(); } } }