C# | C Sharp Tutorial

Visual Studio C# Tutorials – Graphical Operations with C# 2 (Drawing Square – Rectangle, Circle – Ellipse)


System.Drawing.Graphics grafiknesne;
grafiknesne = this.CreateGraphics();
//Elips
Pen firca = new Pen(System.Drawing.Color.Red, 5);
grafiknesne.DrawEllipse(firca, 20, 40, 200, 50);
//Daire
Pen firca1 = new Pen(System.Drawing.Color.Blue, 5);
grafiknesne.DrawEllipse(firca1, 20, 100, 50, 50);

c# MATH OPERATIONS


Create a new C# project and name it MathOperations. Then type:

Console.WriteLine(2 + 6 * 4);
Console.ReadLine();

Run it and you should get the answer 26, not 32. This is because C# will always do multiplication or division first. You can force the answer to be 32, in this case you put brackets around  2 + 6 so it should look like:

Console.WriteLine((2 + 6) * 4);
Console.ReadLine();

This time write:

Console.WriteLine(6 / 3 * 4);

                                                       BACK   Next