public string Source
{
get
{
/*
if ( Source == null ){
return string . Empty;
} else {
return Source;
}
*/
return Source ?? string.Empty;
}
set
{
/*
if ( Source == null ) {
Source = string . Empty;
} else {
if ( Source == value ) {
Source = Source;
} else {
Source = value;
}
}
*/
Source == value ? Source : value ?? string.Empty;
RaisePropertyChanged ( "Source" );
}
}
Can I use ?:
??
operators EXACTLY as If/Else?
My Question :
How to write the following with ?: ?? operators
[ 1 ]
if ( Source == null ){
// Return Nothing
} else {
return Source;
}
[ 2 ]
if ( Source == value ){
// Do Nothing
} else {
Source = value;
RaisePropertyChanged ( "Source" );
}
Briefly : How to do nothing, return nothing and do multiple instructions with ?:
??
operator?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…