Tag: string

convert string to number in c#

To convert a string into a number, we can use either Parse, TryParse, or Convert.Int32, or Convert.ToDouble, etc functions. Here is an example using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication6 { class Program { static void Main(string args) { int num1, num2, num3; string str1, str2; Console.WriteLine("Input first number: ");

C# Split a string into multiple lines in Visual Studio

Here is a simple example, in which we can split a string constant on multiple lines using @ operator using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication6 { class Program { static void Main(string args) { string str = @"coastline along the Arabian Sea and its Gulf of Oman in the