02 January 2019

c#basics File-Explorer-App Menu
MessageBox-Result Open-File-Dialog Color-Dialog

shot.png

We developed together in class a File Explorer which could open images, open text files and color labels
We learned how to create MessaegBox which shows buttons –  and handle the option the user has selected in the message box

More topics covered:

  • Menu-Strip
  • Color-Dialog
  • Open-File-Dialog
  • Loading a file into a picture Bitmap
  • Loading text file into a list of strings (very advanced, not required in this module)

Links:

26 December 2018

c#basics Simon-game MessageBox UI-Thread new-Thread().Start Thread.Sleep const Mono

simon

We developed together in class a Simon game – where the computer plays random colors and you have to repeat them (be careful: one wrong color and your out!)
We learned about the UI thread and creating a new worker thread
We learned about global scope of variables
We learned about Thread.Sleep
We learned how to create MessaegBox using: MessageBox.Show(…);
We learned about WinForm theory, and Mono project

More topics covered:

  • Using const, i.e. const int MAX = 4
  • Setting Colors using Color., i.e. Color.Red
  • Setting Text/Colors from the Form1.Designer.cs
  •  new Thread(() =>
    {
         // put your code here
    }).Start();
  • WinForm Framework theory – .NET versions, GDI, popularity, usage, …, read here: Winform PDF
  • Mono cross-platform, read more about it here: Mono Project
    mono

Links:

19 December 2018

c#basics Whastapp ListBox KeyPress KeyDown Leave DateTime.Now KeyValue

We built a chat Application (like Whatsapp, is typing …)
We learned how to add ListBox and more events into our WinForm application.

More topics covered:

  • ListBox (Add item, get count, set focus)
  • KeyPress event: whenever the user clicked on keyboard inside TextBox
  • KeyDown: here we can detect ENTER key [KeyValue == 13]
  • Leave: whenever the user left the TextBox
  • How to print the current Date-Time
  • How to convert Integer into String , i.e. x.ToString()

Links:

12 December 2018

c#basics Calculator Button TextBox Click-Event Debug.WriteLine

We built our first calculator in Windows Form Application
We learned how to add buttons and click events into our WinForm application.

More topics covered:

  • Text boxes
  • Add Debug messages (to output window)
  • Rename the components in the window (i.e. button, text box etc.)
  • Insert text into Label
  • Add our own function into our WinForm code

Links:

09 December 2018

c#basics Functions advanced, WinForm application, String, boolean

We learned the String and Boolean types and some basic usage.

We saw functions advanced features:
(See C# 5.0 IN A NUTSHELL: page 42)
– Arrays as parameter
– int (primitive) as parameter
– ref
– out
– default values
– params
– destructuring parameters

We created our first Window Forms application
– Hello world!
– Colored in Green 🙂

Links:

05 December 2018

c#basics Functions, Memory Game, WriteLine($), C# website

Cool site to run c# code from the web: https://dotnetfiddle.net/

We learn how to use Console.WriteLine with $. for example:
int x = 10;
Console.WriteLine($”x is equal to : {x}”)

Memory Game project – due date 19/12/2018!

Functions:
– Use to module our code , and re-use the code
– Used with input parameters
– Used with return value

28 November 2018

c#basics Arrays, code snippets

Introduction to Arrays: array is a storage for many elements in a same collection. i.e. list of 100 grades for a class
Array types:
– single dimension []
matrix[,]
jagged[][]

Initialize an array: i.e. array of 10 integers:
int[] grades = new int[10];

Get the array length: grades.length

for loop on the array:
for(int i = 0; i < grades.length; i++) { … }

Code Snippets:
Code snippets are used to paste code into the visual studio with a keyboard shortcut. i.e. “cw” + tab + tab write Console.WriteLine()
So, we can make our on shortcuts. In class we made an example of making a keyboard shortcut “ccr” which pastes:
Convert.ToInt32(Console.ReadLine());
see the video…

21 November 2018

c#basics do-while, continue, break, prime numbers

Topics:
– Learning do-while: same as while except that a first iteration will always occur!
– continue-break out of loops:
continue: will skip to the next iteration
break: will exit the loop
– checking if a number is a prime number or not: run from 2 to number-1 and look for a divider which returns module of zero

Design a site like this with WordPress.com
Get started