🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Burak HABER / C# / Sınıf İçinde Geriye Değer Döndüren Metotlar

1-) C# - Sınıf İçinde Geriye Değer Döndüren Metotlar

(console)

İşlem sınıfı(addClass)

Program.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace islem

{

    class Program

    {

        static void Main(string[] args)

        {

            islem isl = new islem();

            isl.topla(7, 6);

            isl.topla(4, 5);

 

            Console.WriteLine("\n\n\n");

 

            isl.kare(6);

            Console.Read();

        }

    }

}

islem.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace islem

{

    class islem

    {

        public int topla(int s1, int s2)

        {

            int s3 = s1 + s2;

            Console.WriteLine("Sonuc:" + s3);

            return s3;

        }

        public int kare(int deger)

        {

            int sonuc = deger * deger;

            Console.WriteLine("Sonuç: " + sonuc);

            return sonuc;

        }

    }

}



 2021 Mart 11 Perşembe
 459