Visual c net introduction console applications cs 116 laboratory 1
Download
1 / 18

- PowerPoint PPT Presentation


  • 108 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '' - cher


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Visual c net introduction console applications cs 116 laboratory 1

Visual C#.NetIntroduction & Console ApplicationsCS 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


Visual c net introduction console applications cs 116 laboratory 1

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.


Visual c net introduction console applications cs 116 laboratory 1

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.


Visual c net introduction console applications cs 116 laboratory 1

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.


Visual c net introduction console applications cs 116 laboratory 1

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.


Visual c net introduction console applications cs 116 laboratory 1

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.


Visual c net introduction console applications cs 116 laboratory 1

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


Visual c net introduction console applications cs 116 laboratory 1

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


Visual c net introduction console applications cs 116 laboratory 1

Sample Program 1(Inside Class Program)

static void Main(string[] args)

{

Console.Write ("Hello World");

}


Visual c net introduction console applications cs 116 laboratory 1

Sample Program 2(Inside Class Program)

static void Main(string[] args)

{

Console.Write ("Hello World");

Console.ReadKey();

}


Visual c net introduction console applications cs 116 laboratory 1

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();

}


Visual c net introduction console applications cs 116 laboratory 1

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();

}


Visual c net introduction console applications cs 116 laboratory 1

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();

}


Visual c net introduction console applications cs 116 laboratory 1

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();

}


Visual c net introduction console applications cs 116 laboratory 1

Activity#1

First Name:

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


Visual c net introduction console applications cs 116 laboratory 1

Activity#2

Enter Num1:Enter Num2:Sum:Difference:Product:Quotient:


Visual c net introduction console applications cs 116 laboratory 1

Activity#3

Enter Number:[Number] is EVEN.