Avatar of Stacie
Stacie
Flag for United States of America asked on

IsRequiredDateSold = requiredFields[9] == 'T', What does the 9 really mean. Index Value?

I have the following method below and I'm having a hard time understanding what does the following notation mean... The following code is reading from a table and converting it to a variable just not sure why the 9?

requiredFields[9] == 'T',  why a 9?

public static GeneralSetupProgramJobParameter GetProgramJobParameters(
            GeneralSetupProgramJobParameter item,
            string reqdfields,
            string prodparam,
            string chngparam,
            string estutilfld,
            bool defaultStatus0For2ndPrgm
            )
        {
                var requiredFields = reqdfields.ToCharArray();
                var productionDefaults = prodparam.ToCharArray();
                var changeParams = chngparam.ToCharArray();
                var estUtilFields = estutilfld.ToCharArray();

                item.DefaultToStatus0For2ndProgram = defaultStatus0For2ndPrgm;

                item.ProgramJobRequiredFields = new ProgramJobRequiredFields
                {
                    IsRequiredDateSold = requiredFields[9] == 'T',
                    IsRequiredSalesPerson = requiredFields[11] == 'T',
                    IsRequiredSource = requiredFields[10] == 'T',
                    IsRequiredSize = requiredFields[16] == 'T',
                    IsRequiredRoute = requiredFields[14] == 'T',
                    IsRequiredCancelDate = requiredFields[12] == 'T',
                    IsRequiredCancelReason = requiredFields[13] == 'T',
                    IsRequiredRejectReason = requiredFields[15] == 'T',
                    IsRequiredEstimatedBy = requiredFields[26] == 'T',
                };

                item.ProductionDefaults = new ProductionDefaults
                {
                    ProductAmounts = productionDefaults[0] == 'T',
                    StartTime = productionDefaults[1] == 'T',
                    EndTime = productionDefaults[2] == 'T',
                    WindSpeedAndDirection = productionDefaults[4] == 'T',
                    Temperature = productionDefaults[5] == 'T',
                    pH = productionDefaults[6] == 'T',
                    ConditionCodes = productionDefaults[8] == 'T',
                    Rating = productionDefaults[9] == 'T',
                    SaveAssociatedConditions = productionDefaults[7] == 'T',
                    Size = productionDefaults[10] == 'T',
                    Price = productionDefaults[11] == 'T',
                };

Open in new window

.NET MVCC#

Avatar of undefined
Last Comment
Chinmay Patel

8/22/2022 - Mon
Stacie

ASKER
Is it something that was auto generated by VS?
Chris Stanyon

Your function recieves a string called reqdfields. That gets split into a character array and stored in a variable called requiredFields.

This line:

IsRequiredDateSold = requiredFields[9] == 'T'

sets the IsRequiredDateSold variable to either true or false, by checking whether the 10th item in the requiredFields variable is equal to the letter T.
ASKER CERTIFIED SOLUTION
Chinmay Patel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23