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"

25th Jan 2019, 8:10 AM
omar omar
omar omar - avatar
1 Réponse
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.
2nd Jun 2019, 10:13 AM
Maher Najar
Maher Najar - avatar