c# - 为什么定义接口(interface)的方法和属性前面没有修饰符(public、private、protected)?

标签 c#

<分区>

Possible Duplicate:
Is there a reason you can not define the access modifier on a method or in an interface?

你好,

我对接口(interface)很好奇。假设我有以下接口(interface)的定义

public interface IPersone
{
  string FirstName { get; set; }
  string LastName { get; set; }
  int CalculateAge(int YearOfBirth);
}

为什么定义接口(interface)的方法和属性前面没有修饰符(public、private、protected)?有什么理由吗?

感谢帮助

最佳答案

引自 MSDN : 接口(interface)成员始终是公共(public)的,因为接口(interface)的目的是使其他类型能够访问类或结构。

关于c# - 为什么定义接口(interface)的方法和属性前面没有修饰符(public、private、protected)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3111652/

相关文章:

c# - protobuf-net Stream 在返回数据之前被处理

c# - 如何使用 linq 在一个条件下检查列表中的多个值?

c# - 为什么不能从不同的线程更新 ObservableCollection?

c# - 如何使用 INotifyPropertyChanged 更新列表框

c# - 请求 URL "HelloWorld"如何在 ASP.Net MVC 中实例化 HelloWorldController 对象?

c# - 解析 BigInteger 时出现 FormatException

c# - 无锁线程安全

c# - 如何通过 Child ReorderList 中的代码隐藏更改 SqlDataSource 的 ConnectionString 属性?

c# - WCF & CaSTLe Windsor - 看起来你忘了

c# - 如何在 Entity Framework 中使用 Fluent API 以一对多关系映射枚举?