C# | C Sharp Tutorial
by admin | Apr
29, 2021
Visual Studio C# Tutorials – Graphical Operations with C# 2 (Drawing Square – Rectangle, Circle – Ellipse)
We will use the DrawEllipse command for Circle and Ellipse. If the height and width values are the same in the command, the circle will be drawn.
System.Drawing.Graphics grafiknesne;
grafiknesne =
this
.CreateGraphics();
Pen firca =
new
Pen(System.Drawing.Color.Red, 5);
grafiknesne.DrawEllipse(firca, 20, 40, 200, 50);
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