Вы находитесь на странице: 1из 5

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AfficheByIndexOf
{
class Program
{
static void AfficheTab(int[] t)
{
try
{
for(int i=0;i<t.Length/*+2 pour declencher l'exception*/;i++)
Console.WriteLine("t[" + i + "]=" + t[i]);
}
catch (IndexOutOfRangeException)
{
Console.WriteLine("erreur, index pris en dehors des bornes du tableau");
}
}
static void Main(string[] args)
{
int[] t = { 4, 78, 7, 11, 2, 3, 6, 9, 87, 4, 1, 5, 24, 569, 64, 74 };
AfficheTab(t);
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace afficheEntier
{
class Program
{
static void Main(string[] args)
{
Console.Write("donner i:");
Console.WriteLine("i=" + Int32.Parse(Console.ReadLine()));
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace listWeek
{
class Program
{
static void Main(string[] args)
{
List<string> jours = new List<string> { "Lundi", "Mardi", "Mercredi", "Jeudi",
"Vendredi", "Samedi", "Dimanche" };
Console.WriteLine("affichage list:");
foreach (string j in jours)
{
Console.WriteLine(j);
}
jours.RemoveAt(1);
Console.WriteLine("affichage list apres suppression de l'element d'indice
1:");
foreach (string j in jours)
{
Console.WriteLine(j);
}

Console.WriteLine("la position de \"Jeudi\" est:" + jours.IndexOf("Jeudi"));


}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Carre
{
class Carre
{
int Long;

public Carre(int l)
{
Long = l;
}

public long Surface()


{
return Long * Long;

}
}

class Cube: Carre


{
public Cube(int l) :base(l)
{

public long Surface()


{
return (6 * base.Surface());
}
}
class Program
{
static void Main(string[] args)
{
Carre c = new Carre(4);
Cube cu = new Cube(2);

Console.WriteLine("surface du carre est:" + c.Surface());


Console.WriteLine("surface du cube est:" + cu.Surface());
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Point
{
class Point
{
private double x;
private double y;
private static int numPoints;
private double X
{
get
{
return x;
}

set
{
x = value;
}
}
private double Y
{
get
{
return y;
}

set
{
y = value;
}
}

static Point()
{
numPoints = 0;
}
public Point(double xx, double yy)
{

X = xx;
Y = yy;
Console.WriteLine("x=" + X + " et y=" + Y);
numPoints++;
}

public static void NbInstanceActive()


{
Console.WriteLine( numPoints+ " point(s) actif(s)");
}

public void DistanceX_Y(ref Point p)


{
double sqrt = (p.X - X) * (p.X - X) + (p.Y - Y) * (p.Y - Y);
sqrt = Math.Sqrt(sqrt);
Console.WriteLine("Distance="+sqrt);
}

}
class Program
{
static void Main(string[] args)
{
Point p1 = new Point(5, 7);
Point.NbInstanceActive();
Point p2 = new Point(2, 5);
Point.NbInstanceActive();
p2.DistanceX_Y(ref p1);

}
}
}

Оценить