Hey Guys,
Just started working with interfaces and objects for the first time really and I am baffled by this error which appears twice in my code
Error<span style="white-spacere 1<span style="white-spacere
Inconsistent accessibility: parameter type IAccount is less accessible than method IBank.StoreAccount(IAccount)
Error<span style="white-spacere 2<span style="white-spacere
Inconsistent accessibility: parameter type IAccount is less accessible than method program.ArrayBank.StoreAccount(IAccount)
<br/>
Can anyone explain without big technical words why this wont work and maybe how to fix it?
<br/>
<br/>
using System;
<br/>
public interface IBank
{
String FindAccount (string name);
bool StoreAccount (IAccount account);
}
interface IAccount
{
}
public class program
{
public class CustomerAccount : IAccount
{
string name;
decimal balance;
<br/>
<br/>
public CustomerAccount(string InName, decimal InBalance)
{
name = InName;
balance = InBalance;
}
}
<br/>
public class ArrayBank : IBank
{
public ArrayBank[] accounts;
<br/>
<br/>
public ArrayBank(int banksize)
{
accounts = new IAccount[banksize];
<br/>
}
<br/>
public bool StoreAccount(IAccount account)
{
int position = 0; for (position = 0; position < accounts.Length; position++)
{
if (accounts[position] == null)
{
accounts[position] = account;
return true;
}
}
return false;
}
<br/>
public String FindAccount(string name)
{
int position = 0; for (position = 0; position < accounts.Length; position++)
{
if (accounts[position] == null)
{
continue;
}
if (accounts[position].GetName() == name)
{
return accounts[position];
}
}
return null;
}
}
<br/>
<br/>
<br/>
public static void Main()
{
IBank friendlyBank = new ArrayBank(50);
IAccount account = new CustomerAccount("Rob", 0);
<br/>
<br/>
<br/>
}
}
<br/>
Thanks in advance!
<br/>
View the full article
Just started working with interfaces and objects for the first time really and I am baffled by this error which appears twice in my code
Error<span style="white-spacere 1<span style="white-spacere
Inconsistent accessibility: parameter type IAccount is less accessible than method IBank.StoreAccount(IAccount)
Error<span style="white-spacere 2<span style="white-spacere
Inconsistent accessibility: parameter type IAccount is less accessible than method program.ArrayBank.StoreAccount(IAccount)
<br/>
Can anyone explain without big technical words why this wont work and maybe how to fix it?
<br/>
<br/>
using System;
<br/>
public interface IBank
{
String FindAccount (string name);
bool StoreAccount (IAccount account);
}
interface IAccount
{
}
public class program
{
public class CustomerAccount : IAccount
{
string name;
decimal balance;
<br/>
<br/>
public CustomerAccount(string InName, decimal InBalance)
{
name = InName;
balance = InBalance;
}
}
<br/>
public class ArrayBank : IBank
{
public ArrayBank[] accounts;
<br/>
<br/>
public ArrayBank(int banksize)
{
accounts = new IAccount[banksize];
<br/>
}
<br/>
public bool StoreAccount(IAccount account)
{
int position = 0; for (position = 0; position < accounts.Length; position++)
{
if (accounts[position] == null)
{
accounts[position] = account;
return true;
}
}
return false;
}
<br/>
public String FindAccount(string name)
{
int position = 0; for (position = 0; position < accounts.Length; position++)
{
if (accounts[position] == null)
{
continue;
}
if (accounts[position].GetName() == name)
{
return accounts[position];
}
}
return null;
}
}
<br/>
<br/>
<br/>
public static void Main()
{
IBank friendlyBank = new ArrayBank(50);
IAccount account = new CustomerAccount("Rob", 0);
<br/>
<br/>
<br/>
}
}
<br/>
Thanks in advance!
<br/>
View the full article