2012-03-28 98 views
0

在演示WCF,我有一個錯誤時嘗試創造類繼承的IList <>實現接口成員 'System.Collections.IEnumerable.GetEnumerator()'

public class Profileview: IList<Profile> 
{ 
    public Profile ViewProfile(int accountID) 
    { 
     return this.Where(p => p.AccountId == accountID).First(); 
    } 
} 

這是服務

namespace DemoService 
{ 
    [ServiceContract] 
    public interface IProfileService 
    { 
     [OperationContract] 
     Profile ViewProfile(int accountID); 
    } 

    [DataContract] 
    public class Profile 
    { 
     [DataMember] 
     public string FirstName { get; set; } 

     [DataMember] 
     public string LastName { get; set; } 

     [DataMember] 
     public string Location { get; set; } 

     [DataMember] 
     public string Genre { get; set; } 

     [DataMember] 
     public int AccountId { get; set; } 
    } 
} 

錯誤1 'ICService.Profileview' 不實現接口成員 'System.Collections.IEnumerable.GetEnumerator()'

你能告訴我如何解決它。 謝謝:)

回答

0

您不是從IList<Profile>繼承,因爲它是一個接口。你正在實現這個接口,因此你需要實現該接口所需的所有方法 - 這是非常多的。我想你真的想繼承List<Profile>

+0

謝謝!它的工作:) – 2012-03-28 14:21:16

+0

@CongTran:不客氣。請不要忘記接受我的回答:[如何接受答案?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)。 – 2012-03-28 14:22:06

+1

我做到了;)謝謝:D – 2012-03-28 15:00:48

相關問題