I'm doing an assignment where the I should store some string data in arrays. Each new string should be stored in a separate array, that's why I need a method that returns a new array with a name given from a user. What I want is a new array with a uniq name each time I call this method.
On the 2d line I get an error: A local or parameter named '_arrayNameFromUser' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter test
So how do I create a new array with a user-specified name?
A local or parameter named '_arrayNameFromUser' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter test
static string[] NewArary(string arrayNameFromUser)
{
string[] arrayNameFromUser = new string[2];
return arrayNameFromUser;
}
_arrayNameFromUserin the method body - it's a method parameter. So you cannot declare another variable with exactly same name._would indicate a private instance field and not a local variable or method parameter