
For Complete C# Online Training Course Please Visit
Understanding Strings
//string and other types
s = "100";
n = (int) s; //Invalid – String cannot be casted
n = int.Parse(s); //if fails throws, FormatException
bool bln = int.TryParse(s, out n); //If Unsuccessful n will reset to 0
//n = (int) s; //Direct casting of string to int is not allowed.
//int to string
s = n.ToString();
//s = (string) n //Casting of int to string is not allowed
Program to Print the Char equivalent of the Ascii value read from the keyboard
class Program
{static void Main(string[] args)
{
string str;
str = Console.ReadLine();
int n = 100;
if (int.TryParse(str, out n))
Console.WriteLine((char)n);
else
Console.WriteLine("Invalid number");
Try: Write a Program to Read two Integers from Keyboard and Print the sum of these numbers
--------------------------------------------------------------------------------------------------------------------------------------------------------
This video was compiled by Mr. Sandeep Soni, a Microsoft Certified Trainer and an Azure Solution Architect. Know more -
Please subscribe to our channel for more related videos:
For any course-related queries, reach us @ +91 8555823343 / +91 8008327000 Kashmira Shah
Please leave your comment about the videos.
For more updates on courses and tips follow us on:
- Facebook:
- Twitter:
- LinkedIn:
- Website: or
- Join our WhatsApp group -
0 Comments