Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
using System;
namespace Rextester
{
static class Global
{
public static int x=5;
public static int[] array = new int[10];
public static int counter = 0;
public static int i = 1;
};
class Test
{
//...............................
public void LevelLoad()
{
int Level = 0;
Random rnd = new Random();
Level = rnd.Next(3, 8);
Search(Level);
Console.WriteLine("Executed Successfully First Level={0} Counter={1}",Level,Global.counter);
if (Global.x != 0)
{
Console.WriteLine("Executed Successfully in the x if x:{0}",Global.x);
if (Global.counter != 0)
{
Console.WriteLine("---------------in the counter if");
Global.x--;
Global.array[Global.i] = Level;
Global.i++;
Global.counter = 0;
}
}
else
{
Console.WriteLine("Terminated Successfully");
}
}
public void Search(int temp)
{
// int j = 0;
Console.WriteLine("Search function called i:{0}",Global.i);
for(int c=0;c<Global.i;c++)
{
Console.WriteLine("{0}",Global.array[c]);
}
Console.WriteLine("in search counter:{0}",Global.i,Global.counter);
for(int j=0;j<=Global.i;j++)
{
if(Global.array[j]==temp)
{
break;
//Console.WriteLine("{0}",Global.array[j]);
}
else
{
Global.counter++;
Console.WriteLine("In the **********");
}
}
}
//...................................................
public void SayHello()
{
Console.WriteLine("Jithu.......bb") ;
}
}
class Program
{
static void Main(string[] args)
{
Test[] t = new Test[5];
int z;
for(z=0;z<5;z++)
{
Console.WriteLine(" {0} th Iteration",z);
Console.WriteLine("..................................");
t[z]=new Test();
t[z].LevelLoad();
Console.WriteLine("..................................");
}
Console.ReadKey() ;
}
}
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more