Suppose I have a file ABC.CS
in that file I have a class ABC
as below and method Test()
:
public class ABC
{
public
If you are calling the method XYZ.myMethod from Test then myMethod must be a static method. In this case for value type variables, call the method using ref for the value types.
If you need to access the variable, as it seems you need to access a Datatable, directly using the class name or the object reference, you will need to declare the variable as a class variable and make it static.
Once you've done this, try initializing the datatable in the static constructor :
static ABC()
{
ABC.SomeDataTableVariable = new DataTable();
}
Please try this out.