0% found this document useful (0 votes)
50 views

CSE 439: Visual Programming: Prof. Dr. Shamim Akhter Shamimakhter@iubat - Edu

The document provides information about a CSE 439 Visual Programming course taught by Professor Dr. Shamim Akhter. It includes the professor's contact information and background, an outline of the course schedule and topics to be covered including .NET, C#, classes and objects, constructors, and garbage collection. The document contains code examples to demonstrate various .NET and C# programming concepts.

Uploaded by

Mahomuda Akter
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

CSE 439: Visual Programming: Prof. Dr. Shamim Akhter Shamimakhter@iubat - Edu

The document provides information about a CSE 439 Visual Programming course taught by Professor Dr. Shamim Akhter. It includes the professor's contact information and background, an outline of the course schedule and topics to be covered including .NET, C#, classes and objects, constructors, and garbage collection. The document contains code examples to demonstrate various .NET and C# programming concepts.

Uploaded by

Mahomuda Akter
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

CSE 439: Visual Programming

.Net Introduction

@Text Book: Chapter 6


Prof. Dr. Shamim Akhter
[email protected]
About Me
Experience Time Institute
Prof. Shamim Akhter, Ph.D Information Processing, TITECH, Japan
Bachelor (BSc) 1998-2001 American International University-
Bangladesh

Masters (MSc) 2003-2005 Asian Institute of Technology


Thailand

Doctorate (PhD) 2006-2009 Tokyo Institute of Technology


Japan

Post Doctoral 2009-2011 JSPS-NII


Researcher Japan

Assistant Prof. 2005-2014 American International University-


Bangladesh

Contact 2013-2014 Thompson Rivers University (TRU),


Asst. Prof. Kamloops, BC, CANADA

Associate Prof. 2014-2019 East West University

@Dr. Shamim Akhter


Professor 2019- IUBAT

CSC5011
People and Places
Prof. Dr. Shamim Akhter,
Professor, CSE, IUBAT, Bangladesh
http://ca.linkedin.com/pub/dr-md-shamim-akhter/66/966/a3a
[email protected]
Please Call me : Prof. Shamim!, Professor, or Sir
Room Number: 722

Class Schedule –FALL 2020


.Net and C#
 .NET is a free, open-source development platform
 for building many kinds of apps-Web apps, web APIs etc.
 supports integrated development environments (IDEs), and other tools and supports three
programming languages C#, F#, Visual Basic.

 Java has portability but


 lacks cross-language interoperability
 requires for large and distributed software system.
 Assemblies take the form of executable (.exe) or dynamic link library (.dll) files, and are the building
blocks of .NET applications. They provide the common language runtime with the information it needs
to be aware of type implementations.
C
 Not Fully Integrates with windows platforms

@Text Book: Chapter 6


 Universal Windows Platform (UWP) API @ Windows 10
 allows developers to create apps that will potentially run on multiple types of devices. C++
 Development support by C#, JavaScript but not Core Java
 Windows Forms written C#
 Write rich client applications for Labtop, Desktop or Tablet PCs
Java C#
ClassLibrary
Testing Cross-language interoperability
Framework .NET Framework and Common Language Runtime(CLR)
Mix Language Environment-C#, VB

Microsoft Intermediate
Language (MSIL)
Portable Assembly
language

ConsoleApp

@Text Book: Chapter 6


Add Reference
and browse the dll
.NET Code Execution Process
SDK and Runtimes

 .NET SDK is a set of libraries and tools for developing and


running .NET applications.

 SDK download includes the following components:


 .NET CLI: Command-line tools that you can use for local development
and continuous integration scripts.
 dotnet driver: A CLI command that runs framework-dependent apps.
 .NET runtime: Provides a type system, assembly loading, a garbage
collector, native interop, and other basic services.
 Runtime libraries. Provides primitive data types and fundamental
utilities.
Command Line Tool
 Course Objectives and Outcomes.
 Outline Pdf file.
Classes and Objects
 A class is a template that define the forms of an object

Construction

Blueprint/Logical State of a Bike

Field • Instance Variable


• Static/Class Variable

@Text Book: Chapter 6


Members

Function • Constructor, Destructor


• Indexers, Events, Operators
Members and Properties Physical State of Bikes
A Simple Class
 Class is created by use of keyword class.

Instance Variable

@Text Book: Chapter 6


Non-static variable cannot be referenced
without creating class instance
public class VariableExample
{
int myVariable;
static int data = 30;
public static void main(String args[])
{
VariableExample obj = new VariableExample();
System.out.println("Value of instance variable: "+obj.myVariable);
System.out.println("Value of static variable: "+VariableExample.data);
}

@Text Book: Chapter 6


}
Reference Variable and Assignment
Floors 2
using System; house
Area 2500
Occupants 4
class Building{
public int Floors;
Floors 3
public int Area; office
Area 4200
public int Occupants;
Occupants 25
public void areaPerPerson(){ Console.WriteLine("
"+ Area/Occupants + " area per person");
}
}
public class Demo{
static void Main(){
Building house = new Building();
Building office = new Building();

@Text Book: Chapter 6


house.Occupants=4; house.Area=2500; house.Floors=2;
office.Occupants=25; office.Area=4200; office.Floors=3;
house.areaPerPerson();
office.areaPerPerson(); Building house1= new Building();
}
Building house2= house1
}
Constructor
 Constructors
 are special methods called when a class is instantiated.
 will not return anything.
 name is same as class name.
 By default C# will create default constructor internally.
 with no arguments and no body is called default constructor.
 with arguments is called parameterized constructor.
 by default public.
 We can create private constructors.

@Text Book: Chapter 6


 Constructor allocates memory for all instance variables of its
class.
Private Constructor
using System;
namespace ConstructorSample
{
public class Welcome
{
private Welcome() // // Default private constructor
{
Console.WriteLine(“Default Private Constructor...");
} public class demo {
static void Main(string[] args)
{
static void Main(string[] args) Welcome obj = new Welcome();
{ Console.Read();
}

@Text Book: Chapter 6


Welcome obj = new Welcome(); }
Console.Read();
}
}
}
Parameterized Constructor
using System;
public class MyClass
{
public int x;

public MyClass (int i)


{
x=i;
}
}
public class Demo{
static void Main( )
{

@Text Book: Chapter 6


MyClass t1=new MyClass (10);
MyClass t2=new MyClass (88);
Console.WriteLine(t1.x + " " + t2.x);
}
}
Garbage Collection and Destructors
 Recovery of free memory from unused object
 C++ delete operator is used to free allocated memory
 C# and Java: Garbage Collection- automatically
 Can’t know or make assumptions about the timing of garbage collection
 Non-deterministic

 Destructor
 Another method to clean object allocated memory.
 It ensures that a system resource owned by an objet is released.

@Text Book: Chapter 6


 Is declared like constructor except proceed with ~(tilde) -tilda
 No return type and takes no arguments.
Destructor Example
using System;

public class Destructor public class Demo{


{ static void Main( )
public int x; {
int count;
public Destructor (int i) Destructor ob = new Destructor(0);
{ for(count=1; count<1000; count++)
ob.Generator(count);
x=i;
} Console.WriteLine("Done");
~Destructor(){ }
Console.WriteLine("Destructing " + x); }
}

@Text Book: Chapter 6


public void Generator(int i) • No serialization
{ • Non deterministic
Destructor o = new Destructor(i);
}
}
this Keyword
using System;
class Rect{
public int Width;
public int Height;
//public Rect(){ this(3, 2); }
public Rect(int Width, int Height){
this.Width=Width; this.Height=Height;
}
public int Area(){
return this.Width * this.Height;
}
}
class UseRect{

@Text Book: Chapter 6


static void Main(){
Rect r1= new Rect(4,5);
Rect r2= new Rect(7, 9);
Console.WriteLine("Area of r1:" +r1.Area());
Console.WriteLine("Area of r1:" +r2.Area());
}
}

You might also like