Solved

C# - To validate this statement

Posted on 2014-04-30
6
152 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:ocaccy
Comment Utility
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
Comment Utility
@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
Comment Utility
Thank you,
ocaccy.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now