Advertisement

C# Tutorial | Using Strings in Code in C#

C# Tutorial | Using Strings in Code in C# This video will give you a complete training inC# Tutorial | Using Strings in Code in C#

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 -

#deccansoft,#bestdotnettraining,c#,csharp,C# Tutorial,SandeepSoni,string variable,types of string in c#,Understanding Strings,Strings,string and other types,Console.ReadLine,int n,Invalid – String cannot be casted,Console.WriteLine((char)n),class Program,n.ToString(),s = (string) n //Casting of int to string is not allowed,two Integers in C#,Ascii value in C#,Keyboard and Print,Char equivalent,

Post a Comment

0 Comments