Download presentation
Presentation is loading. Please wait.
1
MIS 324 -- Professor Sandvig MIS 324 Professor Sandvig
6/12/2018 C# Language MIS 324 Professor Sandvig
2
MIS 324 -- Professor Sandvig
6/12/2018 Overview C# Basics Variables Data types Control Structures
3
MIS 324 -- Professor Sandvig
6/12/2018 Variables C# strongly typed Similar to VB.NET PHP loosely typed Strongly typed: A variable accepts only one data type Type is explicitly declared when variable is declared
4
Variables C# variables are objects Have properties & methods
FName = FName.Replace(“S”,”P”);
5
MIS 324 -- Professor Sandvig
6/12/2018 Variables Strongly Typed Advantage Less error prone Compiler more likely to catch programming errors Disadvantage Many explicit data type conversions
6
MIS 324 -- Professor Sandvig
6/12/2018 Variables Commonly Used C# Data Types int 123 string “hi” double 1.23 bool true DateTime Jan. 8, :23:46 pm
7
Datatype Conversion Implicit Conversion When no data lost
8
MIS 324 -- Professor Sandvig
6/12/2018 Concatenation Concatenate strings with + string Name = lastName + “, “ + firstName;
9
MIS 324 -- Professor Sandvig
6/12/2018 Outline C# Basics Variables Datatype Conversion Control Structures Collections
10
MIS 324 -- Professor Sandvig
6/12/2018 Control Structures Syntax similar to PHP, Java, C, C++, … Curley brackets for statement blocks if (condition) { //Statement block } else //statement block
11
MIS 324 -- Professor Sandvig
6/12/2018 Control Structures May omit brackets for single statements: if (condition) statement 1; else statement 2;
12
MIS 324 -- Professor Sandvig
6/12/2018 Control Structures Control Statements: if for foreach while
13
MIS 324 -- Professor Sandvig
6/12/2018 Control Structures 1. if else if (condition) { //do something } else if (condition) else //do something else
14
MIS 324 -- Professor Sandvig
6/12/2018 Control Structures 2. for statement increments a counter variable may declare within statement Int sum = 0; for (Int i = 0; i <= 10; i++) { sum += i; }
15
MIS 324 -- Professor Sandvig
6/12/2018 Control Structures 3. foreach loop iterate through collections arrays, controls, cookies, etc. int[] intArray = {3, 5, 7, 9, 11}; int sum = 0; foreach (int item in intArray) { sum += item; }
16
MIS 324 -- Professor Sandvig
6/12/2018 Control Structures 4. while loop int i = 0; while (i < 5) { i += 1; }
17
MIS 324 -- Professor Sandvig
6/12/2018 Control Structures Testing conditions Equality double equal sign if (age == 3) Inequality if (age > 3) Negate if (age != 3) AND / OR && and || or
18
MIS 324 -- Professor Sandvig
6/12/2018 Summary C# modern object oriented programing language Many features that we do not use in 324 C-like syntax (similar to PHP, JavaScript) Strongly typed Explicitly convert data types Pick up syntax quickly Visual Studio big help
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.