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

yguyon28
yguyon28 used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Is it something that was auto generated by VS?
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
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.
Chief Technology Ninja
Distinguished Expert 2018
Commented:
Hi,

Yes it is the index value but the logic of using 9 or for that matter any other index value can't be determined without looking at other parts of the code , especially the input reqdfields string. I am sure it has more to do with the business logic developed by the developer rather the programming that will help you solve this puzzle. You have to debug the code or put alerts/traces to see from this reqdfields is coming and how it is being populated initially.

Regards,
Chinmay.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial