Solved

C# - To validate this statement

Posted on 2014-04-30
6
159 Views
Last Modified: 2014-05-06
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);
            ini.WriteValue("csv","csv_01_01",csv.csv_01_01.ToString());
            ini.WriteValue("csv","csv_01_02",csv.csv_01_02.ToString());
			}
		}

Open in new window


The file for the app to read the values "file.ini":
[csv]
csv_01_01=1611
csv_01_02=1667
csv_01_03=1714
.
csv_01_24=1560
csv_02_01=2116
csv_02_02=2165
csv_02_03=2212
.
csv_02_24=1569
.
csv_12_24=2063

Open in new window

0
Comment
Question by:ocaccy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 250 total points
ID: 40033868
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
0
 
LVL 25

Assisted Solution

by:apeter
apeter earned 250 total points
ID: 40034874
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.
0
 

Author Comment

by:ocaccy
ID: 40036106
Thank you @king2002 and apeter; I`m using the information passed for you to use in my code. I`ll be back soon.
ocaccy
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:ocaccy
ID: 40036444
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!?
0
 

Author Comment

by:ocaccy
ID: 40036449
@apeter,
 If you want to access them as indexers then you should have your TWO properties in csv class as type Dictionary.

How?
0
 

Author Closing Comment

by:ocaccy
ID: 40046063
Thank you,
ocaccy.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question