2016-11-25 5 views
1

사전을 만들었습니다. 그러나 빌드 중에 나에게 오류를 제공합니다사전 세터 문제를 해결하는 방법

Change 'INotificationMessage.AlertMessageList ' to be read-only by removing the property setter

public interface INotificationMessage 
    { 
     /// <summary> 
     /// Gets or sets the notification message list. 
     /// </summary> 
     /// <value> 
     /// The notification message list. 
     /// </value> 
     Dictionary<string, string> AlertMessageList { get; set; } 
    } 

ayone 제발이 문제를 해결하기 위해 저를 도와 드릴 수 있습니다.

답변

2

일반적으로 컬렉션을 공개 할 수 없으므로 목록을 바꿀 수 있습니다. 그냥 사용

Dictionary<string, string> AlertMessageList { get; } 

그것을 해결하기 위해 당신이 수집 또는 사용하는 세트에 대한 방법을 추가 할 수 있습니다

Dictionary<string, string> AlertMessageList { get; private set; } 

Collection properties should be read only

+0

를 참조하십시오 그리고 당신은 목록을 얻기 위해이 implemation를 강제로 설정해야하는 경우 , 그냥 인터페이스에 메서드를 추가 void SetAlertMessageList (Dictionary dict) Dictionary SetAlertMessageList() – user1519979

+0

@Raj Hello. 도움이 되었다면 대답을 수락하십시오. 그렇지 않다면 문제가 무엇인지 설명하십시오. 미리 감사드립니다 – Marusyk

+0

@MegaTron 당신은 속성을 설정하기 위해 인터페이스에 메소드를 추가하는 방법을 제안 할 수 있습니까? – Raj