Converting a list : List : Data Structure C# Examples


C# Examples » Data Structure » List »

 

Converting a list









    
using  System;
using  System.Collections;
using  System.Collections.Generic;
using  System.Collections.ObjectModel;
using  System.Text;

public  class  MainClass
{
        private  static  int  ConvertStringToInt(string  input)
        {
                int  result;
                if  (!int.TryParse(input,  out  result))
                        result  =  -1;
                return  result;
        }
        public  static  void  Main()
        {
                List<string>  stringList2  =  new  List<string>(new  string[]  {  "99",  "182",  "invalid",  "15"  });
                List<int>  intList2  =  stringList2.ConvertAll<int>(ConvertStringToInt);
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» List