190 likes | 329 Views
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
E N D
Visual C#.NetIntroduction & Console ApplicationsCS 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 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.
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.
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.
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.
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.
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
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
Sample Program 1(Inside Class Program) static void Main(string[] args) { Console.Write ("Hello World"); }
Sample Program 2(Inside Class Program) static void Main(string[] args) { Console.Write ("Hello World"); Console.ReadKey(); }
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(); }
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(); }
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(); }
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(); }
Activity#1 First Name: Last Name: Middle Name:Hi, Zyra O Bambico!Welcome to C# Programming.
Activity#2 Enter Num1:Enter Num2:Sum:Difference:Product:Quotient:
Activity#3 Enter Number:[Number] is EVEN.