Here i am pasting the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace star1
{
class Program
{
static void Main(string[] args)
{
Myclass obj = new Myclass();
obj.getData();
obj.pattern();
}
}
class Myclass
{
int i, n, j;
public void getData()
{
Console.WriteLine("Program for displaying pattern of *.");
Console.Write("Enter the maximum number of *: ");
int n = Convert.ToInt32(Console.ReadLine());
}
public void pattern()
{
Console.WriteLine("\nPattern 1 - Left Aligned:\n");
for (i = 1; i <= n; i++) // The Control does not enter the for loop
{
for (j = 1; j <= i; j++)
Console.Write("*");
Console.WriteLine();
}
}
}
}
Looks like you’re redeclaring
nas a local variable ingetData().Try changing that line to:
i.e. remove the
int.