关于界面的疑问 [英] doubt regarding interface
本文介绍了关于界面的疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用系统;
命名空间 Microsoft.AspNet.Identity
{
// 摘要:
// 最小接口具有字符串用户密钥的用户
public interface IUser
{
// 摘要:
// 用户的唯一键
//
// 返回:
// 用户的唯一键
string ID { get ; }
string UserName { get ; set ; }
}
}
我们可以在界面中声明只有常量
可以任何一个解释上面的代码
解决方案
引用:我们只能在接口
没有。
请注意接口有详细记录,请参阅接口(C#编程指南) [ ^ ]。
您发布的代码定义了一个具有两个属性的接口,即只读Id
和读/写UserName
Hi ,
using System;
namespace Microsoft.AspNet.Identity
{
// Summary:
// Minimal interface for a user with a string user key
public interface IUser
{
// Summary:
// Unique key for the user
//
// Returns:
// The unique key for the user
string Id { get; }
string UserName { get; set; }
}
}
we can declare only constant in interface
can any one explain above code
解决方案
Quote:we can declare only constant in interface
No.
Please note interfaces are well documented, see "Interfaces (C# Programming Guide)"[^].
The code you posted defines an interface having two properties, namely the read-onlyId
and the read/writeUserName
.
这篇关于关于界面的疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文