R
Roy Gourgi
Hi,
Is it possible to declare a variable or array in the class that is
accessible to all the methods in the class? For the example below, I would
like to make the variable lnVar1 accessible to both methods m1 and m2 but I
am getting an error. Is there another way to do this?
Thanks
Roy
using System;
using System.Collections.Generic;
using System.Text;
namespace cClasses
{
class Program
{
static void Main(string[] args)
{
AA2.m1();
}
}
}
public class AA2
{
protected int lnVar1 = 0;
public static void m1()
{
Console.Write("M1 {0}", lnVar1);
}
public static void m2()
{
Console.Write("M2 {0}", lnVar1);
}
}
Is it possible to declare a variable or array in the class that is
accessible to all the methods in the class? For the example below, I would
like to make the variable lnVar1 accessible to both methods m1 and m2 but I
am getting an error. Is there another way to do this?
Thanks
Roy
using System;
using System.Collections.Generic;
using System.Text;
namespace cClasses
{
class Program
{
static void Main(string[] args)
{
AA2.m1();
}
}
}
public class AA2
{
protected int lnVar1 = 0;
public static void m1()
{
Console.Write("M1 {0}", lnVar1);
}
public static void m2()
{
Console.Write("M2 {0}", lnVar1);
}
}