0
how to create an array directly inside namespace(without declaring a class)
hello. i have 2 scripts: script-a: namespace a { string[] men={"alfred", "bob"......} } how to make this possible? i dont want to put the array in a class iwant to access it directly from another script using "using a"
1 Odpowiedź
0
Namespaces cannot contain fields or methods. You can encapsulate your array in a class and access it directly from that class with static keyword :
Public class MyClass
{
Public static string[] Mens
{
return {"alfred", "bob", ...}
}
}
Now you can use that class anywhere you want in your program by adding the refererence to the corresponding namespace.