Visual Programming: Jawad Rafeeq Jawadrafeeq@ciitvehari - Edu.pk
Visual Programming: Jawad Rafeeq Jawadrafeeq@ciitvehari - Edu.pk
Visual Programming: Jawad Rafeeq Jawadrafeeq@ciitvehari - Edu.pk
Lecture 1
Jawad Rafeeq
[email protected]
Outline
• What is visual programming
• VPL’s languages
• History
• Features of .NET framework
• Why C#
• C# vs VB
• C# vs Java
What is a VPL?
• A programming language that uses a visual representation (such as
graphics, drawings, animation or icons, partially or completely)
• Any system where the user writes a program using two or more
dimensions [Myers 90]
VPL’s
• There are hundreds of VPL’s
• But mainly:
• VB
• Java
• C#
• etc
History
• Few years back, Microsoft had Visual C++, and VB to compete with java
• Java was catching the market very fast
• Web development and java tools were becoming the most popular
• Microsoft was loosing the battle
• Thousands of programmers moved to java from VC++ and VB
• Then Microsoft put their best man at work for secret project called Next
generation windows services (NGWS) under the supervision of Bill gates
• Outcome of project is the .NET framework
• It has really outperformed their competitors, started late but catching up
quickly
History
• “The .Net framework is a software development platform developed by
Microsoft. The framework was meant to create applications, which would
run on the Windows Platform.”
• “It enables developers to build extensible markup language (XML) web
services and applications”
• Microsoft borrowed most of its idea from JAVA
Feature of .NET framework
• Platform neutral framework
• It is a layer between OS and Programming language
• It supports many programming languages. C#, VB, Asp.net
• It is the part of operating system.
Why C#?
• It is a modern programming language, widely spread, used by
millions of programmers around the entire world.
• C# or VB?
• C# is a language that becomes more and more complex, and there is
no end of aggressive adding complexity (“new features”) in sight.
• In early 2017 that VB .NET was significantly slower in grow, not new
features added to VB (A number of developers feel that VB is a bad
product because it makes development simpler. )
Why C#?
• C# or JAVA?
• C# is undisputedly the better, more powerful, richer and just better
engineered (Fundamentals of Computer Programming with C#)
• Java is just a most popular and widely used language
• C# is deeply integrated with Windows
• C# contain more primitive data types than Java
• C# support enumerations, type-safe data types, and structs
• C# support more useful features that we can overload operators
• And many more will be covered in this course
Why C#?
Getting Started
With C# .NET
Win forms vs
Winforms WPF
WPF
Windows form is an old concept for developing WPF is advance or latest concept for
Advance
desktop applications developing the applications
Windows forms are simple to use as controls can be WPF is complex to use as compared to
Simple
easily used. Windows Forms.
In windows forms, things are achieved at the slower In WPF things are mainly achieved at very
Performance
rate. fast rate comparatively.
Creating a New C# Project
?
A Start with Console Application (.NET framework)
• A project is contained within a solution.
• Despite its name, a solution is not an "answer".
• It's simply a container for one or more related projects, along with build information, Visual
Studio window settings, and various files
• A solution is described by a text file (extension .sln) with its own unique format;
• it's not intended to be edited by hand.
Extension Name Description
.sln Visual Studio Solution Organizes project items, and solution items in the
solution.
Understanding the interface of Visual Studio
• Menu bar
• Tool bar
• Solution Explorer
• Server Explorer
First Program in C#
Solution Explorer Before understanding the Program
• The file called AssemblyInfo.cs contains
information about your programme. Double
click this file to open it up and see the code.
Here's just some of it:
Red color text is something you can change. You can add a Title, Description, Copyright, Trademark, etc.
Solution Explorer Before understanding the Program
• A reference contains the information
• .NET class libraries or assemblies
• COM components
• Other assemblies or class libraries of projects in
the same solution
• XML Web services
https://blog.submain.com/app-config-basics-best-practices/
Solution Explorer Before understanding the Program
Namespaces (.NET namespaces)
Namespaces (User defined namespaces)
Second, declaring your own namespaces can help you control the scope of
classes/functions in larger programming projects.
• // defining the namespace name1
• namespace name1
•{
• Two classes with the same name can be created inside 2 different
namespaces in a single program.
• Inside a namespace, no two classes can have the same name.
• Class can work without namespace, but better practice to work in
namespace
• In C#, the full name of the class starts from its namespace name
followed by dot(.) operator and the class name, which is termed as
the fully qualified name of the class.
How to define own name space (2 class in one namespace)
To make accessible in other namespace
namespace firstNS {
class A To make accessible without declaring object
{ public static void display()
{
System.Console.WriteLine("Hello 1!");
}
}
class B
{
public static void Main(String []args)
{
firstNS.A.display();
}
}
Two name spaces (2 classes in 2 namespaces)
namespace firstNS
{
class A
{
public static void display()
{
System.Console.WriteLine("Hello 1!");
}
}
}
namespace secondNS
{
class B
{
public static void Main(string [] args)
{
firstNS.A.display();
}
}
}
How to define own name space (1 class in namespace, 2nd
without namespace)
using System;
namespace FirstApp
{
class Program
{
public static void display()
{
System.Console.WriteLine("Helloworld");
}
}
}
class abc
{
public static void Main(String[] args)
{
FirstApp.Program.display();
}
}
How to define own name space (1 class without namespace, 2nd
with namespace)
namespace FirstApp
{
class Program
{
public static void Main()
{
abc.display();
System.Console.WriteLine("This is main class");
}
}
}
class abc
{
public static void display()
{
System.Console.WriteLine("Helloworld");
}
}
How to define own name space (Using namespace in program.cs file)
using System;
using ClassSE;
namespace ClassSE
{
class program2
{