Basics #8 + Winforms

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:

 

Basics #7

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 25/11/2019!

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

 

11 NOV 2019

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…

 

Introduction #4

Introduction to:
– Functions: void, parameters, return value
– generating Random numbers: using Random class
– switch-case: ease the long if-else
– Thread.Sleep
– building our first card GAME

Links:

Introduction #3

C# program with more topics:
– if: condition
– if else: condition and false result
– while loop
– WriteLine to the screen
– ReadLine: reads the user input from the keyboard
– Convert.ToInt32: converts a text to an integer (since ReadLine returns a string)

Links:

Introduction #2

We continued with flow charts. we learned about div ( / ), modulo ( % ), &&, || and loops. we practiced three types of loops: do-while, while, for-loop. the next subject was creating c# console application (.NET framework) with visual studio – what do we get “out of the box”? we practiced variables creation using int, float, double and debugged our program using F10 and breakpoints (viewing also the Locals window)

More topics covered:

  • Flow chart: when to use do-while? while? for?
  • Eventually you can choose any loop type you want
  • The better choice of loop type you make- will simplify the program
  • When x % b == 0  it means they divide with no modulo
  • so…    9 % 2 == 1 (e-zugi)    and    8 % 2 == 0 (zugi)
  • x % 10 will give the last digit (ahadot)
  • so…   97 % 10 = 7
  • x / 10 will give you the first digit (asarot)
  • so…   97 / 10 = 9  (the 7 is dropped in div)
  • In VS2017: for debug you can simply click F10
  • float f = 9.9f; (f needs to be added for floats)
  • Also, you can add Breakpoint using F9 and then run using F5
  • Its easier to add breakpoint when you have a long program and you do not want to hurt yourself by clicking F10 many many many times till you reached the desired code section
  • We talked about GIT repository

Links:

Welcome to HackerU!

We talked about the .NET world, the course goals, flow-charts, how to install Visual Studio 2017, and finally we created our first C# “hello world” program using Visual Studio 2017 

More topics covered:

  • Flow chart: Start, Stop, Output, Input, Memory-cell, If statement
  • ==, >=, <= , !=
  • Memory cells must be initialized before usage
  • Tracking table (flow chart)
  • Installing VS 2017 features + language

Links: