❔ How to structure project and import items?
I'm just starting with C#, and I'm having trouble understanding how project structure and importing works.
I come from Rust where you can import a single item from a module with something like
You can also import multiple items using this notation:
I tried something similar in C#:
But that gives an error
I'm also having trouble understanding the relationship between namespaces and files. It seems like you can add stuff to a namespace from anywhere inside your project. So it seems like namespaces are not really self-contained modules, but more like heaps where you can throw in anything semi-related to some concept.
Finally it seems to me like you can't have items private to a module?
This all seems rather unstructured to me, so surely I must be missing something. I can summarize my questions as such:
1. Can you import only specific items?
2. What's the idiomatic way to structure complex libraries? namespace per file?
3. What are the tools to restrict visibility such that I can have parts of my library that are only available internally?
Please bear in mind I'm not familiar with "old-school" OOP stuff so I might be oblivious to the obvious
I would highly appreciate it if you could explain how it works.
I come from Rust where you can import a single item from a module with something like
You can also import multiple items using this notation:
I tried something similar in C#:
But that gives an error
Namespace name expected .... Is it not possible to only import some items from a namespace?I'm also having trouble understanding the relationship between namespaces and files. It seems like you can add stuff to a namespace from anywhere inside your project. So it seems like namespaces are not really self-contained modules, but more like heaps where you can throw in anything semi-related to some concept.
Finally it seems to me like you can't have items private to a module?
This all seems rather unstructured to me, so surely I must be missing something. I can summarize my questions as such:
1. Can you import only specific items?
2. What's the idiomatic way to structure complex libraries? namespace per file?
3. What are the tools to restrict visibility such that I can have parts of my library that are only available internally?
Please bear in mind I'm not familiar with "old-school" OOP stuff so I might be oblivious to the obvious
