Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create C# class that is public inside the DLL but not accessible outside

Tags:

c#

.net

class

Sorry if this question is confusing. I have a public static class inside my project that I want accessible anywhere inside my application. However, I don't want this class exposed when someone else references my DLL in another project.

Is it possible to do this?

Many Thanks!

like image 755
harsimranb Avatar asked Jul 06 '12 17:07

harsimranb


People also ask

What does write () do in C?

The write() function shall attempt to write nbyte bytes from the buffer pointed to by buf to the file associated with the open file descriptor, fildes.

Can you write C in Visual Studio?

The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.


3 Answers

use Internal classes as described in the link.

like image 38
tschmit007 Avatar answered Sep 25 '22 15:09

tschmit007


Use the internal modifier on the class instead of public. You can also make assembly:[InternalsVisibleTo("SomeOtherAssembly")] if you want to make the class accessible to another specific DLL.

like image 121
Joe Castro Avatar answered Sep 25 '22 15:09

Joe Castro


Please read C# documentation at MSDN or if you can read some good book about .net basics. You can specify internal specifier to make class visible inside a namespace.

like image 30
TheVillageIdiot Avatar answered Sep 23 '22 15:09

TheVillageIdiot