Solved

C# - To validate this statement

Posted on 2014-04-30
6
156 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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