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.
Tutorialspoint

Calling Methods in C#

using System;
namespace Rextester
{
static class Global
{
    public static int x=4;
    public static int[] array = new int[10];
    public static int counter = 0;
    public static int i = 0;
     public static int Level = 0;


};

class Test
{
    //...............................
     public void LevelLoad()
    {
         Global.Level = 0;
        Random rnd = new Random();
        Global.Level = rnd.Next(3, 8);
        Console.WriteLine("Executed Successfully First Level={0} Counter={1}",Global.Level,Global.counter);
       Search(Global.Level);
        

        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] = Global.Level;
                Global.i++;
               
              
            } 
        }
        else
        {
            Console.WriteLine("Terminated Successfully");
        }
          Global.counter=0;
    }
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(Global.array[c]);
       }
        Console.WriteLine("in search counter:{0},:{0}",Global.i,Global.counter);
        for(int j=0;j<=Global.i;j++)
        {
              if(Global.array[j]!=temp)
              {
                  
                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
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.