How can I set a variable for a namespace in C #?

I want to declare a global linked list for a namespace in C #. I tried to list the linked list, but I don’t know the correct syntax. can anyone tell me about external variables?

+3
source share
2 answers

I think the C # syntax for extern is much more limited or even radically different from the C ++ world.

http://msdn.microsoft.com/en-US/library/e59b22c5(v=VS.80).aspx .

Perhaps what you really want to implement is a singleton or static member of a class?

// Note: thread safety not implemented...
namespace Sample
{
    public class GlobalLists
    {
        public static List<SomeObject> SomeGlobalObjects;
    }
}

You can then reference the list above as

GlobalLists.SomeGlobalObjects

the rest of the code ...

+1
source

. . , ?

+5

Source: https://habr.com/ru/post/1739841/


All Articles