Dinesh Santhalingam

Dinesh Santhalingam

  • NA
  • 737
  • 367.5k

Get the array element in between a string in c#

Jan 19 2017 1:24 AM
I have the String Array.The array contains following.
  1. String [] Array= {"Age18" ,"Ram","Raj" ,"Sonu","Mano","Age20","Ana","Einstein","Somu"};  
Now here I want to separate the String between Age 18 and Age 20.
  1. foreach (string line in Array)  
  2. {  
  3. if (line.Contains("Age18"))  
  4. {  
  5. //Want to print the Elements of an array before Age20.  
  6. //result [] array={"Age18" ,"Ram","Raj" ,"Sonu","Mano"}; 
  7. }  
Help me to solve this.
 

Answers (8)