Concatenate in C#.

Hello everyone.

I have a very pertinent question.

My x.ini file has the following indices; 8760 if not leap year and 8784 for leap year:

csv_day_hour

csv_001_01=value
csv_001_02=value
csv_001_03=value
csv_001_04=value
...
I need to load these values into an string array.
I'm trying to populate the array with a for loop.

If use "Settings.csv.[" **.[**  the error message is this:  Identifier expected      
If use "Settings.csv[" **[**  the error message is this: Settings.csv' is a 'type', which is not valid in the given context

Any help please.
ocaccy

        private void getMonthHour()
            {
            if(File.Exists(ConfigINI))
                {
                IniFile ini=new IniFile(ConfigINI);
                
                #region Populate the array
                for(int d=1;d<=365;d++) //I'll put the code to not leap years.
                    {
                    for(int h=1;h<=24;h++)
                        {
                        if(d<10)
                            {
                            if(h<10) { sMntHour[d,h]=Settings.csv.["csv_00"+d.ToString()+"_0"+h.ToString()]; }
                            else { sMntHour[d,h]=Settings.csv.["csv_00"+d.ToString()+"_"+h.ToString()]; }
                            }

                        else if (d>10&&d<100)
                            {
                            if(h<10) { sMntHour[d,h]=Settings.csv.["csv_0"+d.ToString()+"_0"+h.ToString()]; }
                            else { sMntHour[d,h]=Settings.csv.["csv_0"+d.ToString()+"_"+h.ToString()]; }
                            }

                        else
                            {
                            if(h<10) { sMntHour[d,h]=Settings.csv.["csv_"+d.ToString()+"_0"+h.ToString()]; }
                            else { sMntHour[d,h]=Settings.csv.["csv_"+d.ToString()+"_"+h.ToString()]; }
                            }
                        }
                    }
                #endregion // Populate the array
                }
            }

Open in new window


error message
ocaccyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Luis PérezSoftware Architect in .NetCommented:
You can try this:

for(int d=1;d<=365;d++) //I'll put the code to not leap years.
                    {
                    for(int h=1;h<=24;h++)
                        {
                             sMntHour[d,h]=Settings.csv.["csv_" + d.ToString("000") + "_" + h.ToString("00")];
                        }
                    }
                #endregion // Populate the array
                }

So you don't need to make an if because you can force the ToString function to return formatted days & hours.

Hope that helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ocaccyAuthor Commented:
Hi Luis,

This help me; bit has problem on concatenation.
0
ocaccyAuthor Commented:
Hi Luis, Thís help me, but in the concatenation has problem.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Jaime OlivaresSoftware ArchitectCommented:
why do you have a dot between Settings.csv and the open bracket?
0
ocaccyAuthor Commented:
Hi Jaime, is because i don't know the sintax.
0
ocaccyAuthor Commented:
This is good!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.