mercredi 27 janvier 2021

Problem with parsing Variable to Return C# -Script Task Transformation

Hey there guys have a little Problem with my Return Value, it will be mapped to the empty string from the beginning. As I am new to c# it might be easy to answer.

Query:

Private static Decimal parseVatWithoutBla(string originalString) // 4,5 inserted {

    var cleanedString = string.Empty;
    //var cleanedString = originalString;

        if (originalString.IndexOf(",") > 0)
        {
            if (originalString.IndexOf(".") > originalString.IndexOf(","))
            {
                cleanedString = originalString.Replace(",", "").Replace(".", ",");
             }
        }
        else if (originalString.IndexOf(".") > 0)
        {
            if (originalString.IndexOf(",") > originalString.IndexOf("."))
            {
                cleanedString = originalString.Replace(".", "");
            }
        }
        else if (originalString.IndexOf(",") == -1 && originalString.IndexOf(".") > 0)
        {
            cleanedString = originalString.Replace(".", ",");
        }
        else
        {
        cleanedString = originalString; //cleanedString =4,5
        }
        return Convert.ToDecimal(cleanedString); // returns the Empty string not the 4,5 why?!

added the comments to describe the problem.

Ty

Aucun commentaire:

Enregistrer un commentaire