Model.Recipe.ToString C# (CSharp) Méthode

ToString() public méthode

public ToString ( ) : string
Résultat string
        public override string ToString()
        {
            string s = "Navne: " + name + ";" + "Type: " + type;
            for (int i = 0; i < IList.Count; i++)
            {
                s = s + ";Ingrediens: " + IList[i][0].ToString() + ". Vægt: " + IList[i][1].ToString() + "Kg";
            }
            s = s + ";Ingrediens: Sukker. Vægt: 2250Kg";
            return s;
        }

Usage Example

        public string ShowProductDocumation(string pName, string pType, string pDocumation)
        {
            if (pNameList.Contains(pName) && pTypeList.Contains(pType) && pDocumationList.Contains(pDocumation))
            {
                if (pDocumation == "Produkt infomation")
                {
                    ProductInfo pi = new ProductInfo(pName, pType);
                    return pi.ToString();
                }
                else if (pDocumation == "Opskirft")
                {
                    Recipe r = new Recipe(pName, pType);
                    return r.ToString();
                }
                else if (pDocumation == "Correspondance")
                {

                }
                else if (pDocumation == "QualityAssurance")
                {

                }
                //database metode til at give data tilbage i en string
            }
            return null;
        }