C#错误:成员名称不能与其封闭类型和接口声明类型相同
我正在尝试为windows Azure提供appFabric服务。我是实现和EchoService,我需要通过方式和IEchoContract接口实现,所有这些都在服务器端。
所以我这样做。
在IEchoContract.cs上
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace Service
{
[ServiceContract(Name = "EchoContract", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
interface IEchoContract
{
public interface IEchoContract
{
[OperationContract]
string Echo(string text);
}
}}
在EchoSErvice.cs上
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace Service
{
class EchoService
{
[ServiceBehavior(Name = "EchoService", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
public class EchoService : IEchoContract
{
public string Echo(string text)
{
Console.WriteLine("Echoing: {0}", text);
return text;
}
}}}
我有两个错误,我不是C#的专家
所以第一个:当我把EchoService:IEchoContract我得到了
'EchoService': member names cannot be the same as their enclosing type
第二,当我把公共接口IEchoContract
'IEchoContract' : interfaces declare types
所以请帮忙。谢谢。
没有找到相关结果
已邀请:
4 个回复
届甸衬丝蚕
EchoService.cs:
bab
尝试删除外部类,因为它没有意义
您还必须删除外部接口,因为它们也被定义了两次(可能是您的类最终定义两次的原因)
逝媳蘑贩茄
俯乡骚钵皆