Τετάρτη 27 Νοεμβρίου 2019


ΜΕΘΟΔΟΙ

1)
using System;

namespace MyApplication
{
  class Program
  {
    static void MyMethod(string fname) 
    {
      Console.WriteLine(fname + " Refsnes");
    }

    static void Main(string[] args)
    {
      MyMethod("Liam");
      MyMethod("Jenny");
      MyMethod("Anja");
    }  
  }
}
2)sing System;

namespace MyApplication
{
  class Program
  {
    static void MyMethod(string country = "Norway")
    {
      Console.WriteLine(country);
    }

    static void Main(string[] args)
    {
      MyMethod("Sweden");
      MyMethod("India");
      MyMethod();
      MyMethod("USA");
    }
  }
}
3)using System;

namespace MyApplication
{
  class Program
  {
    static void MyMethod(string fname, int age)
    {
      Console.WriteLine(fname + " is " + age);
    }

    static void Main(string[] args)
    {
      MyMethod("Liam", 5);
      MyMethod("Jenny", 8);
      MyMethod("Anja", 31);
    }
  }
}
4)using System;

namespace MyApplication
{
  class Program
  {
    static int MyMethod(int x)
    {
      return 5 + x;
    }

    static void Main(string[] args)
    {
      Console.WriteLine(MyMethod(3));
    }
  }
}
5)using System;

namespace MyApplication
{
  class Program
  {
    static int MyMethod(int x, int y)
    {
      return x + y;
    }

    static void Main(string[] args)
    {
      int z = MyMethod(5, 3);
      Console.WriteLine(z);
    }
  }
}
6)


ΑΝΑΚΟΙΝΩΣΗ

Για την πρόοδο της C#  μπορείτε να διαβάσετε από εδω C# μέχρι τους πίνακες .

Επίσης να διαβάσετε τα παραδείγματα που έχουμε κάνει.

Τετάρτη 20 Νοεμβρίου 2019

ΠΙΝΑΚΕΣ
1
using System;

namespace MyApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
      Console.WriteLine(cars[0]);
    }
  }
}
2)using System;

namespace MyApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
      cars[0] = "Opel";
      Console.WriteLine(cars[0]);    
    }
  }
}
3)

using System;

namespace MyApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
      Console.WriteLine(cars.Length);
    }
  }
}
4)using System;

namespace MyApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
      for (int i = 0; i < cars.Length; i++) {
        Console.WriteLine(cars[i]);
      }
    }
  }
}
5)using System;

namespace MyApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
      foreach (string i in cars) 
      {
        Console.WriteLine(i);
      }   
    }
  }
}
6)using System;

namespace ArrayApplication {
   class MyArray {
      static void Main(string[] args) {
         int []  n = new int[10]; /* n is an array of 10 integers */
         int i,j;

         /* initialize elements of array n */
         for ( i = 0; i < 10; i++ ) {
            n[ i ] = i + 100;
         }
         
         /* output each array element's value */
         for (j = 0; j < 10; j++ ) {
            Console.WriteLine("Element[{0}] = {1}", j, n[j]);
         }
         Console.ReadKey();
      }
   }
}

7)