C# - To validate this statement

Hello everyone.

How to fix this error? Thanks in advance, ocaccy

m3h = Convert.ToDouble(Settings.csv["csv_" + Xmonth.ToString("00") + "_" + Xhour.ToString("00")]);

Open in new window

This statement returns this error message:
( 'Monitor.Settings.csv' is a 'type', which is not valid in the given context )
The apps has the Settings.cs class; "I have attached a piece of the class code below".
    public class Settings
		public class csv
            public static string csv_01_01="2345";
            public static string csv_01_02="1650";
	        public static void Write()
            IniFile ini=new IniFile(Monitor.malyt.Folder_users+Monitor.malyt.ConfigINI);

Open in new window

The file for the app to read the values "file.ini":

Open in new window

Who is Participating?
Kamal KhaleefaConnect With a Mentor Information Security SpecialistCommented:
well, in the  class csv your are only defining strings and not properties to be accessed from out side

you can create an object of settings like this
Settings x = new Settings();

then try to use the object x to access properties inside the class

then when you format your string like "csv_01_01" you need to compare it with the values you have in ur file
apeterConnect With a Mentor Commented:
Your Settings is a nested class since it has a class , 'csv' inside.  Also you have all the properties and methods of class 'csv' are static , but the class isn't. So for the 'csv' for to access its method it has also a static class.

Also in your code you are trying to access the csv properties as indexers. And we can't do that because of your csv structure. If you want to access them as indexers then you should have your TWO properties in csv class as type Dictionary.
ocaccyAuthor Commented:
Thank you @king2002 and apeter; I`m using the information passed for you to use in my code. I`ll be back soon.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

ocaccyAuthor Commented:
So, the app has this static properties:
                monthHour[1, 1] = Convert.ToDouble(Settings.csv.csv_01_01);
                monthHour[1, 2] = Convert.ToDouble(Settings.csv.csv_01_02);
                monthHour[1, 3] = Convert.ToDouble(Settings.csv.csv_01_03);
                monthHour[1, 4] = Convert.ToDouble(Settings.csv.csv_01_04);
                monthHour[1, 5] = Convert.ToDouble(Settings.csv.csv_01_05);

Open in new window

Settings x = new Settings(); I need create this object where? setting.cs!?
ocaccyAuthor Commented:
 If you want to access them as indexers then you should have your TWO properties in csv class as type Dictionary.

ocaccyAuthor Commented:
Thank you,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.