Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.7 kB
0
Indexable
Never
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace Vezba
{
    internal class Program
    {
        struct MyStructA
        {
            public int a;
            public int b;
            public MyStructA(int a, int b) { this.a = a;this.b = b; }
            public void Funkcija() { Console.WriteLine("Struct->a: " + a + " , " + b); }
        }

        class MyClassA
        {
            public int a;
            public MyClassA() { a = 10;Console.WriteLine("Con A:"); }
            public virtual void Funkcija() { Console.WriteLine("A_ " + a); }
        }

        class MyClassB:MyClassA
        {
            public int b;
            public MyClassB() { b = 5; Console.WriteLine("Con B:"); }
            public void Funkcija() { Console.WriteLine("B_ " + b); }
        }




        public static void Koren(params int[] niz)
        {
            double a;
            double suma = 0;
            for(int i=0;i<niz.Length;i++)
            {
                a = niz[i];
                a= Math.Sqrt(a);
                suma += a;
            }

            Console.WriteLine(suma);
        }

        static void Main(string[] args)
        {
            try
            {
                
                string path = "C:\\Users\\Djole\\Desktop\\test.txt";
                using (StreamReader sr = new StreamReader(path))
                {

                    string line;
                    while ((line = sr.ReadLine()) != null && line.Contains("stop") == false)
                    {

                        Console.WriteLine(line);

                    }

                }
               

                //Koren(1, 2, 3, 4, 5);

                int b = 5;
                Int32 c = 5;
                String s = "Ja sam string";
                MyClassB p1 = new MyClassB();
                MyClassA p2 = new MyClassA();
                MyClassA p3 = p2;
                p3.a = 20;
                MyStructA p4 = new MyStructA(10, 20);
                p4.a += 15;
                Console.WriteLine("P1");
                p1.Funkcija();
                Console.WriteLine("P2");
                p2.Funkcija();
                Console.WriteLine("P3");
                p3.Funkcija();
                Console.WriteLine("P4");
                p4.Funkcija();





            }
            catch (Exception ex)
            {
                Console.WriteLine("Greska: " +ex);
                Console.WriteLine();
            }


        }
    }
}