SlideShare a Scribd company logo
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
C#
Day 1
Lecture5: Type Casting
Type Casting
using System;
namespace dataType
{
class Program
{
static void Main(string[] args)
{
int a = 1;
int b = 2;
short result = (short) (a + b);
Console.WriteLine(result);
Console.Read();
}
}
}
Type Casting
using System;
namespace dataType
{
class Program
{
static void Main(string[] args)
{
string String1 = "123";
int a = Int32.Parse(String1);
Console.WriteLine(a);
Console.Read();
}
}
}
Type Casting
using System;
namespace dataType
{
class Program
{
static void Main(string[] args)
{
string String1 = "123";
string String2 = "321";
int c = Int32.Parse(String1) + Int32.Parse (String2);
Console.WriteLine(c);
Console.Read();
}
}
}
Type Casting
using System;
namespace dataType
{
class Program
{
static void Main(string[] args)
{
string String2 = "321";
int b = Convert.ToInt32(String2);
Console.WriteLine(b);
Console.Read();
}
}
}
Type Casting
using System;
namespace dataType
{
class Program
{
static void Main(string[] args)
{
string String1 = "123";
string String2 = "321";
int c = Convert.ToInt32 (String1) + Convert.ToInt32(String2);
Console.WriteLine(c);
Console.Read();
}
}
}
Type Casting
using System;
namespace dataType
{
class Program
{
static void Main(string[] args)
{
string String1 = "123";
string String2 = "321";
int c = Int32.Parse.ToInt32 (String1) + Convert.ToInt32(String2);
Console.WriteLine(c);
Console.Read();
}
}
}
Type Casting
using System;
namespace dataType
{
class Program
{
static void Main(string[] args)
{
double d = 123.998;
int e = (int)d;
Console.WriteLine(e);
Console.Read();
}
}
}
Type Casting
using System;
namespace dataType
{
class Program
{
static void Main(string[] args)
{
string String1 = "123";
int a = Int32.Parse(String1);
object obj = a;
int r = (int)obj;
Console.WriteLine(r);
Console.Read();
}
}
}
This slide is provided as a course material in the workshop named
“Workshop on C# Programming: Learn to Build”.
Organized by-
East West University Computer Programming Club (EWUCoPC)
Prepared by-
Jannat Binta Alam
Campus Ambassador
Young Engineers Society (YES)
E-mail: jannat.cse.ewu@gmail.com

More Related Content

What's hot (19)

PDF
Reactive Programming in the Browser feat. Scala.js and PureScript
Luka Jacobowitz
 
PDF
(Kpi summer school 2015) theano tutorial part1
Serhii Havrylov
 
PPT
2CPP16 - STL
Michael Heron
 
PPTX
Theano tutorial
Serhii Havrylov
 
PPTX
Constructor and destructor
rajshreemuthiah
 
PDF
An Introduction to the C++ Standard Library
Joyjit Choudhury
 
PPT
Python advanced 3.the python std lib by example – application building blocks
John(Qiang) Zhang
 
PDF
Building a Tagless Final DSL for WebGL
Luka Jacobowitz
 
PPTX
Machine Learning in H2O
Aakash Gupta
 
PDF
Cocoaheads Meetup / Alex Zimin / Swift magic
Badoo Development
 
PPTX
Operators and expression in c++
ThamizhselviKrishnam
 
PPTX
Stack Data structure
B Liyanage Asanka
 
DOCX
Exp 6.1 d-422-1
Omkar Rane
 
PPTX
Streams&io
PhD Research Scholar
 
PPT
Playing the toStrings
Konstantin Pavlov
 
PPTX
Pa2 session 1
aiclub_slides
 
PPTX
An introduction to java programming
hoshmand kareem
 
PPTX
CSharp for Unity - Day 1
Duong Thanh
 
Reactive Programming in the Browser feat. Scala.js and PureScript
Luka Jacobowitz
 
(Kpi summer school 2015) theano tutorial part1
Serhii Havrylov
 
2CPP16 - STL
Michael Heron
 
Theano tutorial
Serhii Havrylov
 
Constructor and destructor
rajshreemuthiah
 
An Introduction to the C++ Standard Library
Joyjit Choudhury
 
Python advanced 3.the python std lib by example – application building blocks
John(Qiang) Zhang
 
Building a Tagless Final DSL for WebGL
Luka Jacobowitz
 
Machine Learning in H2O
Aakash Gupta
 
Cocoaheads Meetup / Alex Zimin / Swift magic
Badoo Development
 
Operators and expression in c++
ThamizhselviKrishnam
 
Stack Data structure
B Liyanage Asanka
 
Exp 6.1 d-422-1
Omkar Rane
 
Streams&io
PhD Research Scholar
 
Playing the toStrings
Konstantin Pavlov
 
Pa2 session 1
aiclub_slides
 
An introduction to java programming
hoshmand kareem
 
CSharp for Unity - Day 1
Duong Thanh
 

Similar to Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build) (20)

PPTX
19csharp
Sireesh K
 
PPTX
19c
Sireesh K
 
PPT
Introduction to C#
ANURAG SINGH
 
PPT
Introduction of C# BY Adarsh Singh
singhadarsh
 
PPTX
SPF Getting Started - Console Program
Hock Leng PUAH
 
PPTX
Getting Started - Console Program and Problem Solving
Hock Leng PUAH
 
PPTX
Chapter 2 c#
megersaoljira
 
PPTX
data types in C-Sharp (C#)
Abid Kohistani
 
PPTX
04. Console Input Output
Intro C# Book
 
PPTX
2 programming with c# i
siragezeynu
 
PDF
C# Data Types and Comments_Lecture2_C#.pdf
Azhar Babil
 
PPTX
Core C# Programming Constructs, Part 1
Vahid Farahmandian
 
PPTX
5variables in c#
Sireesh K
 
PPTX
Getting started with C# Programming
Bhushan Mulmule
 
PPTX
CSharp Language Overview Part 1
Hossein Zahed
 
PDF
434090527-C-Cheat-Sheet. pdf C# program
MAHESHV559910
 
PPT
Synapseindia dot net development
Synapseindiappsdevelopment
 
PPT
Introduction To C#
SAMIR BHOGAYTA
 
PPT
C Language fundamentals hhhhhhhhhhhh.ppt
lalita57189
 
DOCX
Unit 1 question and answer
Vasuki Ramasamy
 
19csharp
Sireesh K
 
Introduction to C#
ANURAG SINGH
 
Introduction of C# BY Adarsh Singh
singhadarsh
 
SPF Getting Started - Console Program
Hock Leng PUAH
 
Getting Started - Console Program and Problem Solving
Hock Leng PUAH
 
Chapter 2 c#
megersaoljira
 
data types in C-Sharp (C#)
Abid Kohistani
 
04. Console Input Output
Intro C# Book
 
2 programming with c# i
siragezeynu
 
C# Data Types and Comments_Lecture2_C#.pdf
Azhar Babil
 
Core C# Programming Constructs, Part 1
Vahid Farahmandian
 
5variables in c#
Sireesh K
 
Getting started with C# Programming
Bhushan Mulmule
 
CSharp Language Overview Part 1
Hossein Zahed
 
434090527-C-Cheat-Sheet. pdf C# program
MAHESHV559910
 
Synapseindia dot net development
Synapseindiappsdevelopment
 
Introduction To C#
SAMIR BHOGAYTA
 
C Language fundamentals hhhhhhhhhhhh.ppt
lalita57189
 
Unit 1 question and answer
Vasuki Ramasamy
 
Ad

More from Jannat Ruma (8)

PPTX
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
PPTX
Class C# - Lec11 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
PPTX
String C# - Lec10 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
PPTX
Method C# - Lec8 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
PPTX
Loop C# - Lec7 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
PPTX
Decision Making C# - Lec6 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
PPTX
Variable C# - Lec5 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
PPTX
Operator C# - Lec3 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Class C# - Lec11 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
String C# - Lec10 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Method C# - Lec8 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Loop C# - Lec7 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Decision Making C# - Lec6 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Variable C# - Lec5 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Operator C# - Lec3 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Ad

Recently uploaded (20)

PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 

Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)

  • 3. Type Casting using System; namespace dataType { class Program { static void Main(string[] args) { int a = 1; int b = 2; short result = (short) (a + b); Console.WriteLine(result); Console.Read(); } } }
  • 4. Type Casting using System; namespace dataType { class Program { static void Main(string[] args) { string String1 = "123"; int a = Int32.Parse(String1); Console.WriteLine(a); Console.Read(); } } }
  • 5. Type Casting using System; namespace dataType { class Program { static void Main(string[] args) { string String1 = "123"; string String2 = "321"; int c = Int32.Parse(String1) + Int32.Parse (String2); Console.WriteLine(c); Console.Read(); } } }
  • 6. Type Casting using System; namespace dataType { class Program { static void Main(string[] args) { string String2 = "321"; int b = Convert.ToInt32(String2); Console.WriteLine(b); Console.Read(); } } }
  • 7. Type Casting using System; namespace dataType { class Program { static void Main(string[] args) { string String1 = "123"; string String2 = "321"; int c = Convert.ToInt32 (String1) + Convert.ToInt32(String2); Console.WriteLine(c); Console.Read(); } } }
  • 8. Type Casting using System; namespace dataType { class Program { static void Main(string[] args) { string String1 = "123"; string String2 = "321"; int c = Int32.Parse.ToInt32 (String1) + Convert.ToInt32(String2); Console.WriteLine(c); Console.Read(); } } }
  • 9. Type Casting using System; namespace dataType { class Program { static void Main(string[] args) { double d = 123.998; int e = (int)d; Console.WriteLine(e); Console.Read(); } } }
  • 10. Type Casting using System; namespace dataType { class Program { static void Main(string[] args) { string String1 = "123"; int a = Int32.Parse(String1); object obj = a; int r = (int)obj; Console.WriteLine(r); Console.Read(); } } }
  • 11. This slide is provided as a course material in the workshop named “Workshop on C# Programming: Learn to Build”. Organized by- East West University Computer Programming Club (EWUCoPC) Prepared by- Jannat Binta Alam Campus Ambassador Young Engineers Society (YES) E-mail: [email protected]