Introduction to C#.Net Software programming - Lecture 03

Department of Technical Education & Training (DTET) 
College of Technology Jaffna 
 National Vocational Qualification Level 5 
Information and Communication Technology 
Lecture 03 
 Introduction to C#.Net Software programming 
 Module Code: K72C001M04

 
 

C# - Program Structure Example 01

using System;
namespace HelloWorldApplication
{
class HelloWorld

{
static void Main(string[] args) {
/* my first program in C# */
Console.WriteLine("Hello World");
Console.ReadKey();

} } }

C# - Program Structure Example 01
using System;
namespace RectangleApplication
{
class Rectangle { // member variables
double length;
double width;
public void Acceptdetails()
{ length = 4.5; width = 3.5; }
public double GetArea() {
return length * width; }
public void Display() {
Console.WriteLine("Length: {0}", length);
Console.WriteLine("Width: {0}", width);
Console.WriteLine("Area: {0}",
GetArea()); } }
class ExecuteRectangle {
static void Main(string[] args)
{
Rectangle r = new Rectangle();
r.Acceptdetails();
r.Display();
Console.ReadLine(); } } }



 K.Thiruthanigesan, BSc. University College of Jaffna University of Vocational Technology

Post a Comment

0 Comments