为什么没有修饰符(公共,私有,保护)在定义一个接口的方法和属性面前? [英] Why there's no modifiers (public, private, protected) in front of methods and properties defining an interface?
本文介绍了为什么没有修饰符(公共,私有,保护)在定义一个接口的方法和属性面前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
的是否有你不能定义一个方法或接口的访问修饰符理由吗?
您好:
我很好奇接口。比方说,我有以下接口的定义
I'm curious about interfaces. Let's say I've the following interface's definition
public interface IPersone
{
string FirstName { get; set; }
string LastName { get; set; }
int CalculateAge(int YearOfBirth);
}
为什么没有修饰符(公共,私有,保护)的方法前,属性定义一个接口?没有任何理由是什么?
Why there's no modifiers (public, private, protected) in front of methods and properties defining an interface? Is there any reason for that?
感谢您的帮助。
推荐答案
从 MSDN :接口成员始终是公开的,因为其目的接口是使其他类型的访问类或结构。的
这篇关于为什么没有修饰符(公共,私有,保护)在定义一个接口的方法和属性面前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文