Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# - To validate this statement

Posted on 2014-04-30
6
Medium Priority
?
167 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 1000 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 1000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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