SlideShare una empresa de Scribd logo
1 de 13
C# Tutorial
Part 19:Typecasting
www.siri-kt.blogspot.com
• we can convert one datatype into different datatypes.
• it is classified into 2 types
• 1.implicit type casting
• 2.explicit type casting
• 1.implicit type casting:
• In this we convert lower datatypes are converts into higher data types.it is also called
as internal type casting. It is under control of clr;
• using System;
• namespace implicittypecastin_exm
• { class Program
• { static void Main(string[] args)
• { int i = 545454;//4 bytes
• long l = i;//8 bytes
• Console.WriteLine("the long value is:" + l.ToString());
• Console.ReadLine();
• } } }
• 2.Explicit type casting:
• In this we convert higher datatypes converts into lower datatypes. it is also called as
external type casting. this is under control of the programmer
• using System;
• namespace implicittypecastin_exm
• { class Program
• { static void Main(string[] args)
• { long l = 454545454;//8 bytes
• int i = l;//4 bytes
• Console.WriteLine("the int value is:" + i.ToString());
• Console.ReadLine();
• } } }
• the above example gives error. cant implicit convert higher to lower datatypes. we can
overcome this problem.explit type casting classified into
• 3 types :
• 1.c++ style type casting
• 2.parsing
• 3.converting
• 1.c++ style type casting:
• in this type casting higher datatypes are converts into lower datatypes.
• ex:
• long l = 454545454;//8 bytes
• int i =(int) l;//4 bytes
• Console.WriteLine("the int value is:" + i.ToString());
• Console.ReadLine();
• 2.working with parsing:
• as .net all the datatypes are predefined structures.
• int i;
• int-structure
• i-structure variable.
C# Type Conversion Methods
C# provides the following built-in type conversion methods:
Methods & Description
ToBoolean Converts a type to a Boolean value, where possible.
ToByte Converts a type to a byte.
ToChar Converts a type to a single Unicode character, where possible.
ToDateTime Converts a type (integer or string type) to date-time structures.
ToDecimal Converts a floating point or integer type to a decimal type.
ToDouble Converts a type to a double type.
ToInt16 Converts a type to a 16-bit integer.
ToInt32 Converts a type to a 32-bit integer.
ToInt64 Converts a type to a 64-bit integer.
ToSbyte Converts a type to a signed byte type.
ToSingle Converts a type to a small floating point number.
ToString Converts a type to a string.
ToType Converts a type to a specified type.
ToUInt16 Converts a type to an unsigned int type.
ToUInt32 Converts a type to an unsigned long type.
ToUInt64 Converts a type to an unsigned big integer.
• structure is a collection of predefined methods
• 1.minvalue()
• 2.maxvalue()
• 3.tostring()
• 4.parse()
• working with parse() is called as parsing. parse() method can be used only to convert
from strings into int. tostring() can be used only to convert from int to string.
• ex: print the limits of datatypes.
• static void Main(string[] args)
• { Console.WriteLine(byte.MinValue.ToString());
• Console.WriteLine(byte.MaxValue.ToString());
• Console.WriteLine(int.MinValue.ToString());
• Console.WriteLine(int.MaxValue.ToString());
• Console.ReadLine(); }
• 2.example on parsing
• 1.take the form
• 2.add 3 labels,3 textboxes,1 button control
• private void button1_Click(object sender, EventArgs e)
• { textBox3.Text = textBox1.Text + textBox2.Text; }
• o/p:1010
• it gives concatenation error
• ex:
• "10"+"10"=1010
• 10+10=20;
• we can overcome this problem using parsing method..
• textBox3.Text = (int.Parse(textBox1.Text)
+int.Parse(textBox2.Text)).ToString();
• 2 nd method:
• private void button1_Click(object sender, EventArgs e)
• { // textBox3.Text =
(int.Parse(textBox1.Text)
+int.Parse(textBox2.Text)).ToString();
• int a, b, c;
• a = int.Parse(textBox1.Text);
• b = int.Parse(textBox2.Text);
• c = a + b;
• textBox3.Text = c.ToString();
• }
• Working with converting method:
• working with convert class is called as converting.
• convert is the part fcl(frame work class library)
• convert is the collection of predefined methods
• convert.toint16()-short-2 bytes
• convert.toint32()-int-4 bytes
• convert.toint64()-long-8 bytes
• convert.tochar()
• convert.tobyte()
• convert.toboolean()
• convert.tofloat()
• convert.todouble()
• Example on converting:
• take the form
• 2.add 3 labels,3 textboxes,1 button control
• private void button1_Click(object sender, EventArgs e)
• { textBox3.Text = textBox1.Text + textBox2.Text; }
• o/p:1010
• it gives concatenation error
• ex:"10"+"10"=1010
• 10+10=20;
• we can overcome this problem using parsing method..
• textBox3.Text = (convert.toint32(textBox1.Text)
+convert.toint32(textBox2.Text)).ToString();
• 2 nd method:
• private void button1_Click(object sender, EventArgs e)
• {
• // textBox3.Text = (int.Parse(textBox1.Text)
+int.Parse(textBox2.Text)).ToString();
• int a, b, c;
• a = convert.toint16(textBox1.Text);
• b = convert.toint16(textBox2.Text);
• c = a + b;
• textBox3.Text = c.ToString();
• }
For more visit our website www.siri-kt.blogspot.com
Thanks for
Watching
More Angular JS TutorialsMore C sharp (c#) tutorials

Más contenido relacionado

La actualidad más candente

Object oriented programming 9 expressions and type casting in c++
Object oriented programming 9 expressions and type casting in c++Object oriented programming 9 expressions and type casting in c++
Object oriented programming 9 expressions and type casting in c++Vaibhav Khanna
 
Computer data type and Terminologies
Computer data type and Terminologies Computer data type and Terminologies
Computer data type and Terminologies glyvive
 
5variables in c#
5variables in c#5variables in c#
5variables in c#Sireesh K
 
SHA- Secure hashing algorithm
SHA- Secure hashing algorithmSHA- Secure hashing algorithm
SHA- Secure hashing algorithmRuchi Maurya
 
Aes128 bit project_report
Aes128 bit project_reportAes128 bit project_report
Aes128 bit project_reportNikhil Gupta
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input OutputBharat17485
 

La actualidad más candente (14)

Intake 37 6
Intake 37 6Intake 37 6
Intake 37 6
 
Learning python
Learning pythonLearning python
Learning python
 
Intake 37 5
Intake 37 5Intake 37 5
Intake 37 5
 
MD-5 : Algorithm
MD-5 : AlgorithmMD-5 : Algorithm
MD-5 : Algorithm
 
C Omega
C OmegaC Omega
C Omega
 
30csharp
30csharp30csharp
30csharp
 
Object oriented programming 9 expressions and type casting in c++
Object oriented programming 9 expressions and type casting in c++Object oriented programming 9 expressions and type casting in c++
Object oriented programming 9 expressions and type casting in c++
 
Computer data type and Terminologies
Computer data type and Terminologies Computer data type and Terminologies
Computer data type and Terminologies
 
SHA 1 Algorithm
SHA 1 AlgorithmSHA 1 Algorithm
SHA 1 Algorithm
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
 
SHA- Secure hashing algorithm
SHA- Secure hashing algorithmSHA- Secure hashing algorithm
SHA- Secure hashing algorithm
 
MD5
MD5MD5
MD5
 
Aes128 bit project_report
Aes128 bit project_reportAes128 bit project_report
Aes128 bit project_report
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
 

Similar a 19c

Ifi7184.DT lesson 2
Ifi7184.DT lesson 2Ifi7184.DT lesson 2
Ifi7184.DT lesson 2Sónia
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C ProgrammingQazi Shahzad Ali
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ toolAbdullah Jan
 
What is Data Types and Functions?
What is Data Types and Functions?What is Data Types and Functions?
What is Data Types and Functions?AnuragSrivastava272
 
Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxRonaldo Aditya
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.pptFatimaZafar68
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp fullVõ Hòa
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Learning python
Learning pythonLearning python
Learning pythonFraboni Ec
 
Learning python
Learning pythonLearning python
Learning pythonJames Wong
 
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)Dilawar Khan
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 

Similar a 19c (20)

Ifi7184.DT lesson 2
Ifi7184.DT lesson 2Ifi7184.DT lesson 2
Ifi7184.DT lesson 2
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ tool
 
What is Data Types and Functions?
What is Data Types and Functions?What is Data Types and Functions?
What is Data Types and Functions?
 
Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptx
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.ppt
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Data types in c++
Data types in c++ Data types in c++
Data types in c++
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 

Más de Sireesh K (20)

Cn10
Cn10Cn10
Cn10
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
What is mvc
What is mvcWhat is mvc
What is mvc
 
31c
31c31c
31c
 
31cs
31cs31cs
31cs
 
45c
45c45c
45c
 
44c
44c44c
44c
 
43c
43c43c
43c
 
42c
42c42c
42c
 
41c
41c41c
41c
 
40c
40c40c
40c
 
39c
39c39c
39c
 
38c
38c38c
38c
 
37c
37c37c
37c
 
35c
35c35c
35c
 
34c
34c34c
34c
 
33c
33c33c
33c
 
30c
30c30c
30c
 
29c
29c29c
29c
 

Último

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Último (20)

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

19c

  • 2. • we can convert one datatype into different datatypes. • it is classified into 2 types • 1.implicit type casting • 2.explicit type casting • 1.implicit type casting: • In this we convert lower datatypes are converts into higher data types.it is also called as internal type casting. It is under control of clr; • using System; • namespace implicittypecastin_exm • { class Program • { static void Main(string[] args) • { int i = 545454;//4 bytes • long l = i;//8 bytes • Console.WriteLine("the long value is:" + l.ToString()); • Console.ReadLine(); • } } }
  • 3. • 2.Explicit type casting: • In this we convert higher datatypes converts into lower datatypes. it is also called as external type casting. this is under control of the programmer • using System; • namespace implicittypecastin_exm • { class Program • { static void Main(string[] args) • { long l = 454545454;//8 bytes • int i = l;//4 bytes • Console.WriteLine("the int value is:" + i.ToString()); • Console.ReadLine(); • } } } • the above example gives error. cant implicit convert higher to lower datatypes. we can overcome this problem.explit type casting classified into
  • 4. • 3 types : • 1.c++ style type casting • 2.parsing • 3.converting • 1.c++ style type casting: • in this type casting higher datatypes are converts into lower datatypes. • ex: • long l = 454545454;//8 bytes • int i =(int) l;//4 bytes • Console.WriteLine("the int value is:" + i.ToString()); • Console.ReadLine(); • 2.working with parsing: • as .net all the datatypes are predefined structures. • int i; • int-structure • i-structure variable.
  • 5. C# Type Conversion Methods C# provides the following built-in type conversion methods: Methods & Description ToBoolean Converts a type to a Boolean value, where possible. ToByte Converts a type to a byte. ToChar Converts a type to a single Unicode character, where possible. ToDateTime Converts a type (integer or string type) to date-time structures. ToDecimal Converts a floating point or integer type to a decimal type. ToDouble Converts a type to a double type. ToInt16 Converts a type to a 16-bit integer. ToInt32 Converts a type to a 32-bit integer.
  • 6. ToInt64 Converts a type to a 64-bit integer. ToSbyte Converts a type to a signed byte type. ToSingle Converts a type to a small floating point number. ToString Converts a type to a string. ToType Converts a type to a specified type. ToUInt16 Converts a type to an unsigned int type. ToUInt32 Converts a type to an unsigned long type. ToUInt64 Converts a type to an unsigned big integer.
  • 7. • structure is a collection of predefined methods • 1.minvalue() • 2.maxvalue() • 3.tostring() • 4.parse() • working with parse() is called as parsing. parse() method can be used only to convert from strings into int. tostring() can be used only to convert from int to string. • ex: print the limits of datatypes. • static void Main(string[] args) • { Console.WriteLine(byte.MinValue.ToString()); • Console.WriteLine(byte.MaxValue.ToString()); • Console.WriteLine(int.MinValue.ToString()); • Console.WriteLine(int.MaxValue.ToString()); • Console.ReadLine(); }
  • 8. • 2.example on parsing • 1.take the form • 2.add 3 labels,3 textboxes,1 button control • private void button1_Click(object sender, EventArgs e) • { textBox3.Text = textBox1.Text + textBox2.Text; } • o/p:1010 • it gives concatenation error • ex: • "10"+"10"=1010 • 10+10=20; • we can overcome this problem using parsing method.. • textBox3.Text = (int.Parse(textBox1.Text) +int.Parse(textBox2.Text)).ToString();
  • 9. • 2 nd method: • private void button1_Click(object sender, EventArgs e) • { // textBox3.Text = (int.Parse(textBox1.Text) +int.Parse(textBox2.Text)).ToString(); • int a, b, c; • a = int.Parse(textBox1.Text); • b = int.Parse(textBox2.Text); • c = a + b; • textBox3.Text = c.ToString(); • }
  • 10. • Working with converting method: • working with convert class is called as converting. • convert is the part fcl(frame work class library) • convert is the collection of predefined methods • convert.toint16()-short-2 bytes • convert.toint32()-int-4 bytes • convert.toint64()-long-8 bytes • convert.tochar() • convert.tobyte() • convert.toboolean() • convert.tofloat() • convert.todouble()
  • 11. • Example on converting: • take the form • 2.add 3 labels,3 textboxes,1 button control • private void button1_Click(object sender, EventArgs e) • { textBox3.Text = textBox1.Text + textBox2.Text; } • o/p:1010 • it gives concatenation error • ex:"10"+"10"=1010 • 10+10=20; • we can overcome this problem using parsing method.. • textBox3.Text = (convert.toint32(textBox1.Text) +convert.toint32(textBox2.Text)).ToString();
  • 12. • 2 nd method: • private void button1_Click(object sender, EventArgs e) • { • // textBox3.Text = (int.Parse(textBox1.Text) +int.Parse(textBox2.Text)).ToString(); • int a, b, c; • a = convert.toint16(textBox1.Text); • b = convert.toint16(textBox2.Text); • c = a + b; • textBox3.Text = c.ToString(); • }
  • 13. For more visit our website www.siri-kt.blogspot.com Thanks for Watching More Angular JS TutorialsMore C sharp (c#) tutorials