In this tip we will see, can we assign access modifiers(Public/Private/Protected/internal/Protected Internal)) to Interface method signatures.
public /internal interface Itest
{
protected
int ProtectedMethod(); //Compile
Error
internal
int internalMethod();//Compile
Error
private
int privateMethod();//Compile
Error
protected
internal int
ProtectedInternalMethod();//Compile Error
public int publicMethod();//Compile
Error
}
when we try to add any of access modifiers to interface methods we will get compile time error as "The modifier 'public/protected/private/internal ' is not valid for this item". Even we can not assign a public modifier to methods.
But we can add Public/internal modifiers for an interface name.
0 Comments:
Post a Comment