Download presentation
Presentation is loading. Please wait.
1
Visual Programming Lecture 3
2
Introduction to C# Applications
Console.WriteLine() method Comments Single line Multi line Keywords Contextual Keywords C# is case sensitive language Display line numbers in editor Use Tools > Options… Under “Text Editor > All Languages” select “Line numbers”
3
Continued… Changing the name of application file IntelliSense feature
Use Properties window IntelliSense feature Saving the application Compiling and Running the Application Compiler may create .exe, .dll or other files called assemblies These assemblies contain MSIL code Console.ReadKey() method Role of Ctrl+F5 command Discussion on “Error List” window If not visible use “View > Error List”
4
Continued… Parameter info window Error List Window
Shows the description of the syntax error in the code (red underlined) Difference between Console.Write() and Console.WriteLine() method Displaying multiple lines with a single statement Console.WriteLine(“Welcome\nto\nC#\nProgramming”); Escape sequences \n, \t, \\, \” Displaying formatted text Console.WriteLine(“{0}\n{1}”,”Welcome to”, “C# Programming!”);
5
Another C# Application – Adding Integers
Console.Write("Enter first integer: "); number1 = Console.ReadLine(); Problems with this code Solution number1 = Convert.ToInt32(Console.ReadLine());
6
Complete Program int number1; int number2; int sum;
Console.Write("Enter first integer: "); number1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter second integer: "); number2 = Convert.ToInt32(Console.ReadLine()); sum = number1 + number2; Console.WriteLine("Sum is {0}", sum);
7
Miscellaneous Topics Data types
Int, long, char, string, float, double, decimal, bool Console.ReadKey() and Console.ReadLine() methods Arithmetic operators +, -, *, /, %, ++ (prefix and postfix), -- (prefix and postfix) Relational operators ==, !=, >, <, >=, <= Logical operators &&, &, ||, |, ! Compound Assignment Operators *=, +=, -=, /=, %=, &=, |=, ^=
8
Exercise Write a program which will ask user to enter 3 double values and then show their product.
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.