我在我的程序的构造函数的属性/访问器方法中有类似这样的内容。在C中替换/更改空白或空字符串值#
using System;
namespace BusinessTrips
{
public class Expense
{
private string paymentMethod;
public Expense()
{
}
public Expense(string pmtMthd)
{
paymentMethod = pmtMthd;
}
//This is where things get problematic
public string PaymentMethod
{
get
{
return paymentMethod;
}
set
{
if (string.IsNullOrWhiteSpace(" "))
paymentMethod = "~~unspecified~~";
else paymentMethod = value;
}
}
}
}
当输入一个新的属性时,PaymentMethod为空或空格,这显然不起作用。有任何想法吗?
,只是重写直接字段值('旅行=')assingnment与财产setter调用('旅行=') – Mikant 2012-02-18 05:59:50