Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Different Star Pattern Programs in C#
Like any other programming languages such as C, C++, Java, we can easily display start pattern programs in C#.

Let us see them one by one.
Example
using System.IO;
using System;
class Program {
static void Main() {
for (int i = 1; i <= 6; ++i) {
for (int j = 1; j <= i; ++j) {
Console.Write("*");
}
Console.WriteLine();
}
}
}
Output
* ** *** **** ***** ******
Let us see another series.
Example
using System.IO;
using System;
class Program {
static void Main() {
int i, j, k;
int n = 6,
// loop to print the series
for (i = 1; i <= n; i++) {
for (j = 1; j <= n - i; j++) {
Console.Write(" ");
}
for (k = 1; k <= i; k++) {
Console.Write("*");
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
Output
* ** *** **** ***** ******
Let us see another series.
Example
using System.IO;
using System;
class Program {
static void Main() {
for (int i = 6; i >= 1; --i) {
for (int j = 1; j >= i; ++j) {
Console.Write("*");
}
Console.WriteLine();
}
}
}
Output
****** ***** **** *** ** *
Here is another series.
Example
using System.IO;
using System;
class Demo {
static void Main() {
int a = 1, spaces, k = 6, i = 0, j = 0;
spaces = k - 1;
for(i=1; i<k*2; i++) {
for(j=1; j<=spaces; j++) {
Console.Write(" ");
}
for(j=1; j<a*2; j++) {
Console.Write("*");
}
Console.WriteLine("");
if(i < k) {
spaces--;
a++;
} else {
spaces++;
a--;
}
}
}
}
Output
* *** ***** ******* ********* *********** ********* ******* ***** *** *
Advertisements