Skip to main content
1 de 2
Cpp
  • 23
  • 1
  • 8

(local variable) int PlaceNumberValue Error: Cannot Implicity convert type 'int' to 'string'

Buenas noches les dejo este pequeño error no puedo convertir la variable 'PlaceNumberValue' de string a entero aqui les dejo el codigo:

using System; using System.Collections.Generic; using System.Linq; using System.Text;

namespace TrackerLibrary { /// /// Represent what the prize if for the given place. /// public class PrizeModel { /// /// The unique identifier for the prize /// public int Id { get; set; } /// /// The numeric identifier for the place(for the second place, etc.) /// public int PlaceNumber { get; set; } /// /// The friendly name for the place (second place, first runner up, etc.) ///

    public string PlaceName { get; set; }

    /// <summary>
    /// The find amount this place earns or zero if it is not used.
    /// </summary>

    public decimal PrizeAmount { get; set; }
    /// <summary>
    /// The number that represent the percentage of theoverall take or
    /// zero if it is not used. The percentage if a fraction of 1 (so O.S for
    /// 50%)
    /// </summary>

    public double PrizePercentage { get; set; }

    public PrizeModel()
    {

    }

    public PrizeModel(string placeName, string placeNumber, string placeAmount, string placePercentage)
    {
        PlaceName = PlaceName;
        int placeNumberValue = 0;
        int.TryParse(placeNumber, out placeNumberValue);
        placeNumber = placeNumberValue; //AQUI ESTA EL ERROR

        decimal prizeAmountValue = 0;
        decimal.TryParse(prizeAmount, out prizeAmountValue);
        PrizeAmount = prizeAmountValue;
    }


    public string prizeAmount { get; set; }
}

}

Cpp
  • 23
  • 1
  • 8