我是一个完整的C#新手,请原谅我的无知。
我正在尝试将字符串值解析为视图模型。作为 LineOne、LineTwo 和 LineThree 属性的一部分,我很难将数据库 DateTime 和 Boolean 值转换为字符串。我该怎么做呢?
private void mapChecks() 
{
    bool FoundResult = false;
    // Check if object is loaded
    if (Items.Count == 0)
    {
    //Add everything
        foreach (xtn_UnresolvedCheck check in MyChecks)
        {
                Items.Add(new ItemViewModel
                    {
                        LineOne = check.ClientName,
                        LineTwo = check.NSMDateTime,
                        LineThree = check.HaveRead,
                        MyappId = check.MonitoringID
          }
        );
    }
}
项目视图模型:
namespace App
{
    public class ItemViewModel : INotifyPropertyChanged
    {
        private int _myappId;
        public int MyappId
        {
            get
            {
                return _myappId;
            }
            set
            {
                if (value != _myappId)
                {
                    _myappId = value;
                    NotifyPropertyChanged("MyappId");
                }
            }
        }
    private bool _isFavorite;
    public bool IsFavorite
    {
        get
        {
            return _isFavorite;
        }
        set
        {
            if (value != _isFavorite)
            {
                _isFavorite = value;
                NotifyPropertyChanged("IsFavorite");
            }
        }
    }
    private string _lineOne;
    public string LineOne
    {
        get
        {
            return _lineOne;
        }
        set
        {
            if (value != _lineOne)
            {
                _lineOne = value;
                NotifyPropertyChanged("LineOne");
            }
        }
    }
    private string _lineTwo;
    public string LineTwo
    {
        get
        {
            return _lineTwo;
        }
        set
        {
            if (value != _lineTwo)
            {
                _lineTwo = value;
                NotifyPropertyChanged("LineTwo");
            }
        }
    }
    private string _lineThree;
    public string LineThree
    {
        get
        {
            return _lineThree;
        }
        set
        {
            if (value != _lineThree)
            {
                _lineThree = value;
                NotifyPropertyChanged("LineThree");
            }
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(String propertyName)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (null != handler)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}