What is the use case for the (C# 7.2) “private protected” modifier?

Before C# 7.2 we had protected internal modifier. This really means protected OR internal, that is – member A is accessible to child classes and also to any class in the current assembly, even if that class is not child of class A (so restriction implied by “protected” is relaxed). private protected really means protected … Read more

Why can’t I have protected interface members?

I think everyone hammered the point of an interface having only public members, no implementation details. What you are looking for is an abstract class. public interface IOrange { OrangePeel Peel { get; } } public abstract class OrangeBase : IOrange { protected OrangeBase() {} protected abstract OrangePips Seeds { get; } public abstract OrangePeel … Read more

Static block in Java not executed

A static final int field is a compile-time constant and its value is hardcoded into the destination class without a reference to its origin; therefore your main class does not trigger the loading of the class containing the field; therefore the static initializer in that class is not executed. In specific detail, the compiled bytecode … Read more

What are public, private and protected in object oriented programming?

They are access modifiers and help us implement Encapsulation (or information hiding). They tell the compiler which other classes should have access to the field or method being defined. private – Only the current class will have access to the field or method. protected – Only the current class and subclasses (and sometimes also same-package … Read more

Any reason to write the “private” keyword in C#?

AFAIK, private is the default everywhere in C# (meaning that if I don’t write public, protected, internal, etc. it will be private by default). (please correct me if wrong). This is not true. Types defined within a namespace (classes, structs, interfaces, etc) will be internal by default. Also, members within different types have different default … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)