Created an array in a file called tablearray.cs. I want to use it on another page. getting Table.Rate is inaccessible due to protection level.
First i have an array below is a part of it.
namespace testarray
{
public partial class Table
{
double[,] Rate = new double[,]
{
{ 0.25, 0.384615385, 0.153846154 },
{ 0.255, 0.395348837, 0.15503876 },
{ 0.26, 0.40625, 0.15625 },
{ 0.265, 0.417322835, 0.157480315 },
{ 0.27, 0.428571429, 0.158730159 },
I placed the following code in the same file
public Tuple<double, double, double> GetRates(double input)
{
double PercentToGive = 0;
double ValueStore = 0;
double ValueAdmin = 0;
foreach (int x in Rate)
{
if (Rate[x, 0] == input)
{
PercentToGive = Rate[x, 0];
ValueStore = Rate[x, 1];
ValueAdmin = Rate[x, 2];
break;
}
}
and than in the page to call this
Tuple<double, double, double> resultTuple = Table.GetRates(Convert.ToDouble(txtInput.Text));
I get this error
CS0120 An object reference is required for the non-static field, method, or property ‘Table.GetRates(double)’
Then i copied the Getrates to the same page that i call the function on.
` public Tuple<double, double, double> GetRates(double input)
{
double PercentToGive = 0;
double ValueStore = 0;
double ValueAdmin = 0;
foreach (int x in Table.Rate)
{
if (Rate[x, 0] == input)
{
PercentToGive = Rate[x, 0];
ValueStore = Rate[x, 1];
ValueAdmin = Rate[x, 2];
break;
}`
Table.Rate is inaccessable due to its protection level.
I have looked online and can’t find the answer