How to count the number of row in string

In above image i will get the input given in the image in string i need to get the number of line in the string
For example based on the given image i need to get the output as 2


can you try the following

yourString.Split({Environment.NewLine}, StringSplitOptions.None).Count.ToString


1 Like

Use as below.

OutStr=InputStr.Split({Environment.NewLine}, StringSplitOptions.None).Count.ToString

where OutStr will give you the count
InoutStr is the Input string

Getting the count as one

plz share the text file which you are trying to count.

Same file which i have shared I cannot share the original file .shared file is a replica of the original one

Hi @sruthesanju

try something like this

  1. Read the text file and store in string str1

  2. Now use the below code to get the count of lines


Thanks & Regards,
Nived N

check this


Hi @sruthesanju ,

Could you try with the Below Expression :


or the below Expression :


Hello @sruthesanju


Where Mytext is the input string

Hi @sruthesanju ,

You can try the below code

System.IO.File.ReadAllLines("Your full file path").Length