I can't declare it as private in another class because I have several classes that use it. I also don't want it to be internal otherwise it will be exposed to other classes in the same assembly. I want it to be accessible just to the classes in the same file. Is it possible in C#?
<< is the left shift operator. It is shifting the number 1 to the left 0 bits, which is equivalent to the number 1 .
In C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs.
The && (logical AND) operator indicates whether both operands are true. If both operands have nonzero values, the result has the value 1 . Otherwise, the result has the value 0 . The type of the result is int . Both operands must have an arithmetic or pointer type.
There's very little in the C# language which is done at at the level of "source file".
The closest you could come would be to create a top-level class and have several nested classes:
class Foo
{
internal class A
{
private Shared shared = new Shared();
}
internal class B
{
private Shared shared = new Shared();
}
private class Shared
{
}
}
It's not a very pleasant solution though, to be honest. If a class needs to be visible to a number of other classes, I'd typically prefer to make it internal and either extract out those classes to another assembly or live with the shared class being visible to other clsses in the same assembly which don't really need to know about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With