0

I have some different settings type and assigned values which need to read it during the runtime as per the customer choice.

Type of the settings are specializedstringcollection and want to call it from the method ReadString() ;

 public static void ReadStrings(StringCollection MyString)

    {

        // Reading from settings as per user decision

        List<string> lines =Properties.Settings.Default.MyString.Cast<string>().ToList();

The code is giving an error ;

"'object' does not contain a definition for 'Cast' and the best extension method overload 'Queryable.Cast(IQueryable)'

Would you please let me know how can i read different settings types as per the user decision

Ali
  • 33
  • 9
  • I don't see any decisions in that code ... – Fildor Nov 16 '18 at 13:57
  • I will make the decision in other class and assign it to MyString by calling this method – Ali Nov 16 '18 at 14:02
  • 1
    What are you attempting to do with `Properties.Settings.Default.MyString.Cast().ToList();` ? Are you just attempting to retrieve all the properties? Why not just use `SettingsPropertyCollection list = Properties.Settings.Default.Properties;` and then loop through the properties and retrieve their value? – Chris Nov 16 '18 at 14:06
  • I dont need to read all the properities just the specific one ( as per the user decision) and assign it to List collection to use. Actually i prefer to use settings instead of reading from a textfile – Ali Nov 16 '18 at 14:13
  • Addition: Each settings have a big strings like ASCii art strings and i believe that it takes time of i read it all at one time – Ali Nov 16 '18 at 14:20
  • @HansPassant Actually MyString is not a settings which is recorded at properties.setting, it is just a variable which i will retrieve from the user and send to method to read, for example if MyString="xxx" then method ReadStrings("xxx") should be read properties.settings.xxx.Cast().ToList() . Sorry for my novice level that i have some improper use of the coding but need your advice to mover forward. – Ali Nov 16 '18 at 15:27

0 Answers0