如何在C#中以字符串格式替换double?

时间:2013-07-24 13:57:47

标签: c# .net windows-phone-7 xaml windows-phone-8

如何用double替换字符串来计算C#中下面代码中的“距离”(而不是时间)?距离最初为0.00。试图通过Windows Phone中的Sqlite发布值。

private string time = string.Empty;
        public string Time
        {
            get { return time; }
            set { if (SetProperty(ref time, value)) IsDirty = true; }
        }

//需要将值放在下面的行中。

internal CustomerViewModel(int id, double pace, string time, double distance )
        {
            this.id = id;
            this.pace = pace;
            this.time = time;
            this.distance = distance;                      
            this.isDirty = false;
        }

1 个答案:

答案 0 :(得分:2)

我不知道我是否理解你的问题,但这就是你的意思:

private double time = 0.00;
    public double Time
    {
        get { return time; }
        set { if (SetProperty(ref time, value)) IsDirty = true; }
    }

修改

private double distance = 0.0;
    public double Distance
    {
        get { return this.distance; }
        set { 
            this.distance = value;
            IsDirty = true; }
    }