Desgine Create with For Loop

Hi Friends you know something about the star(*) print in console application. I have given many interview on .net application. Every time asking print the star(*) and how many loop are needed and so on. So I think this is very use full every one. So, I solve the problem and share with C# Corner website users.

This loop design in Console Application. If you think have any problem in this loops plz share with me and i know my English not good.

  1. static void Main(string[] args)  
  2. {  
  3.     Console.WriteLine("Enter Your Name ");  
  4.     string temp=Console.ReadLine();  
  5.     Console.WriteLine("");  
  6.     Console.WriteLine("");  
  7.     Console.WriteLine("");  
  8.     string temp2 = temp;  
  9.     string temp3 = "";  
  10.     temp += " ";  
  11.     temp2 += " ";  
  12.     for (int i = temp.Length-1; i >0 ; i--)  
  13.     {  
  14.         temp3 += " ";  
  15.         Console.WriteLine("{0}"+temp3 +"{1}", temp.Remove(i), (temp2.Remove(i)));  
  16.   
  17.     }  
  18.     temp3 += " ";  
  19.     for (int i = 1; i < temp.Length; i++)  
  20.     {  
  21.         Console.WriteLine("{0}"+temp3.Remove(temp3.Length-i-i-i+1)+"{1}", temp.Remove(i), (temp2.Remove(i)));  
  22.   
  23.     }  
  24.     Console.WriteLine("");  
  25.     Console.WriteLine("");  
  26.     Console.WriteLine("");  
  27. }  
Output

output

Happy Coding

Ebook Download
View all
FileInfo in C#
Read by 9.7k people
Download Now!
Learn
View all