I am trying to extract only numbers from a text file in c# -


i trying extract numbers text file in c#. text file below

xasd 50 ysd 20 zaf 40 bhar 60 

i trying browse file openfiledialoug , read file , extract numbers same file , need compare values constant value 60. need display how many numbers present more constant number. if numbers greater 60 need append number of greater values richtextbox along existing text.

you can use int32.tryparse(string s,out int result) method. returns true if string s can parsed integer , stores value in int result. also, can use string.split(char[]) method split line read text file.

 string line = fileobject.readline();  int constant = 60; //for example  int num = 0;  string []tokens = line.split(); //no arguments in method means space used delimeter  foreach(string s in tokens)  {      if(int32.tryparse(s, out num)      {          if(num > constant)          {              //logic append rich text box          }      }  } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -