1
NULLプロパティを検証したい場合、NULLの場合は空の文字列を返したいと思います。そのために私はクラス以下のように作成しました:returingする前にヌルプロパティを確認する
public class TestValue
{
public string CcAlias
{
get
{
return string.IsNullOrEmpty(CcAlias) ? string.Empty : CcAlias;
}
set
{
CcAlias = CcAlias ?? string.Empty;
}
}
}
とコードの下で私のクラスをテストした:
System.StackOverflowException was unhandled
HResult=-2147023895
Message=Exception of type 'System.StackOverflowException' was thrown.
InnerException:
カスタムコードをまったく実行している場合、自動プロパティは使用できません。カスタム機能の場合(あなたがやっているような)、あなた自身でプロパティのコードを実装する必要があります(メンバー変数からの値の格納と取得を含む)。 –