I have this code in C# but I have a problem whit this code:
struct myStruct
{
public string sOne;
public string sTwo;
}
public static int ChangeStruct(out myStruct[] arrmyStruct)
{
arrmyStruct= new myStruct[256];
arrSNChildrenStruct[0].sOne= "";
arrSNChildrenStruct[0].sTwo= "";
return 0;
}
But when I build, I have this error: Inconsistent accessibility: parameter type 'out ........ is less accessible than method .....
What's wrong? Thanks
This has nothing to do with it being an out
parameter, or an array. You'd get the same error with:
public static void ChangeStruct(myStruct foo)
Your method is public, but your struct is internal
(the default accessibility for any top-level type) or private
if it's a nested type. That means that any caller external to your assembly should have access to the method... but can't possibly understand the method signature. C# doesn't allow you to declare methods which refer to types which can't be seen by all possible callers.
Options:
internal
or private
Other notes:
See more on this question at Stackoverflow