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.
- static void Main(string[] args)
- {
- Console.WriteLine("Enter Your Name ");
- string temp=Console.ReadLine();
- Console.WriteLine("");
- Console.WriteLine("");
- Console.WriteLine("");
- string temp2 = temp;
- string temp3 = "";
- temp += " ";
- temp2 += " ";
- for (int i = temp.Length-1; i >0 ; i--)
- {
- temp3 += " ";
- Console.WriteLine("{0}"+temp3 +"{1}", temp.Remove(i), (temp2.Remove(i)));
-
- }
- temp3 += " ";
- for (int i = 1; i < temp.Length; i++)
- {
- Console.WriteLine("{0}"+temp3.Remove(temp3.Length-i-i-i+1)+"{1}", temp.Remove(i), (temp2.Remove(i)));
-
- }
- Console.WriteLine("");
- Console.WriteLine("");
- Console.WriteLine("");
- }
Output
Happy Coding