1 / 18

Visual C#.Net Introduction & Console Applications CS 116 – Laboratory 1

Visual C#.Net Introduction & Console Applications CS 116 – Laboratory 1. A Simple C# Console Application one that looks like a DOS window File -> New Project -> Console Application Take Note: Name, Location, Solution Name. Solution (. sln ) file

noble-kidd
Download Presentation

Visual C#.Net Introduction & Console Applications CS 116 – Laboratory 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual C#.NetIntroduction & Console ApplicationsCS 116 – Laboratory 1

  2. A Simple C# Console Application one that looks like a DOS window File -> New Project -> Console Application Take Note: Name, Location, Solution Name

  3. Solution (.sln) file are the solution files. It stores info about the collection of projects that make up whatever you are developing. They contain projects, source control settings, or any other global level thing. Solution User Options (.suo) file are user settings files. Completely disposable, you can delete it and the most common thing you will lose are breakpoints.

  4. CSProj file the actual code projects (C# Libraries, WCF Services, etc). It stores information at the project level. It wraps all relevant References, Classess, etc. App.config At its simplest, the app.config is an XML file with built-in configuration sections and the ability to add your own custom settings.

  5. using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; Solution Explorer Right side. This is where all the files for your project are.

  6. Namespace keyword Includes the name of your application. A namespace is a way to group related code together The namespace keyword is used to declare a scope that contains a set of related objects. You can use a namespace to organize code elements and to create globally unique types.

  7. Namespace keyword Includes the name of your application. A namespace is a way to group related code together The namespace keyword is used to declare a scope that contains a set of related objects. You can use a namespace to organize code elements and to create globally unique types.

  8. Class keyword Classes are declared using the keyword class. [class] class identifier { class-body }[;] All your code will be written in classes. This one is called Program

  9. Method: Main static void Main(string[] args) { } When you run your programme, C# looks for a Method called Main. It uses the Main Method as the starting point for your programmes

  10. Sample Program 1(Inside Class Program) static void Main(string[] args) { Console.Write ("Hello World"); }

  11. Sample Program 2(Inside Class Program) static void Main(string[] args) { Console.Write ("Hello World"); Console.ReadKey(); }

  12. Sample Program 3(Inside Class Program) static void Main(string[] args) { Console.WriteLine("Hello World"); string fname; Console.Write("Enter your first name: "); fname = Console.ReadLine(); Console.WriteLine("Hello {0}", fname); Console.ReadKey(); }

  13. Sample Program 4(Inside Class Program) static void Main(string[] args) { Console.WriteLine("Hello World"); string fname, lname; Console.Write("Enter your first name: "); fname = Console.ReadLine(); Console.Write("Enter your last name: "); lname = Console.ReadLine(); Console.WriteLine("Hello {0} {1}!", fname,lname); Console.ReadKey(); }

  14. Sample Program 5(Inside Class Program) static void Main(string[] args) { constint feet = 12; intval, ans; Console.WriteLine("Conversion inches to feet"); Console.Write("Enter your value in inches: "); val = int.Parse(Console.ReadLine()); ans = val * feet; Console.WriteLine("Value is {0}", ans); Console.ReadKey(); }

  15. Sample Program 6(Inside Class Program) static void Main(string[] args) { Console.Write("Enter your value: "); int x; x = int.Parse(Console.ReadLine()); if (x < 10) Console.Write("{0} is less than 10",x); else Console.Write("{0} is greater than 10",x); Console.ReadKey(); }

  16. Activity#1 First Name: Last Name: Middle Name:Hi, Zyra O Bambico!Welcome to C# Programming.

  17. Activity#2 Enter Num1:Enter Num2:Sum:Difference:Product:Quotient:

  18. Activity#3 Enter Number:[Number] is EVEN.

More Related