Resolved Another issue from a beginner C# programmer.

C# learner

Active member
Joined
Dec 22, 2022
Messages
40
Programming Experience
Beginner
I created a method that uses a value parameter to be used to find a record in a file and out parameters. I learned how to get the out parameters initialized, but having trouble with the first parameter, idIndividualID. I don't want to null the field because the value is used in the if statement to find the correct record. Why is the field highlighted in red? Error says " The name idIndividualID does not exist in the current context".
C#:
 static void FindIndRecord (string idIndividualID, // field in question
                                          out string idSurname,
                                          out string idGivenName,
                                          out string idBirthDate,
                                          out string idBirthPlace,
                                          out string idMarriageDate,
                                          out string idMarriagePlace,
                                          out string idDeathDate,
                                          out string idDeathPlace,
                                          out string idSex,
                                          out string idChildCode,
                                          out string idParentCode)
                             
                {
                   
                    idSurname = null;
                    idGivenName = null;
                    idBirthDate = null;
                    idBirthPlace = null;
                    idMarriageDate = null;
                    idMarriagePlace = null;
                    idDeathDate = null;
                    idDeathPlace = null;
                    idSex = null;
                    idChildCode = null;
                    idParentCode = null;
                }

                {   
                    // While control variable
                    string recordLine;
                   

                    string path = (@"C:\Users\steve\OneDrive\Documents\Donna's Documents\Steves stuff\Family Tree Development Folder\GEDCOM Individual Data.csv");
                    using StreamReader id = new StreamReader(path, true);
                    {
                        while ((recordLine = id.ReadLine()) != null)
                        {
                           
                            // using the split method to parse "line" into lineParts array
                            string[] lineParts = recordLine.Split(',');

                            //string trimIndividualID = null;
                             if (lineParts[1] = idIndividualID  //field in question
                            {
                                string idSurname = (lineParts[2] != null && lineParts[2] != " ") ? lineParts[2] : " ";
                                string idGivenName = (lineParts[3] != null && lineParts[3] != " ") ? lineParts[3] : " ";
                                string idBirthDate = (lineParts[4] != null && lineParts[4] != " ") ? lineParts[4] : " ";
                                string idBirthPlace = (lineParts[5] != null && lineParts[5] != " ") ? lineParts[5] : " ";
                                string idMarriageDate = (lineParts[6] != null && lineParts[6] != " ") ? lineParts[6] : " ";
                                string idMarriagePlace = (lineParts[7] != null && lineParts[7] != " ") ? lineParts[7] : " ";
                                string idDeathDate = (lineParts[8] != null && lineParts[8] != " ") ? lineParts[8] : " ";
                                string idDeathPlace = (lineParts[9] != null && lineParts[9] != " ") ? lineParts[9] : " ";
                                string idSex = (lineParts[10] != null && lineParts[10] != " ") ? lineParts[10] : " ";
                                string idChildCode = (lineParts[11] != null && lineParts[11] != " ") ? lineParts[11] : " ";
                                string idParentCode = (lineParts[12] != null && lineParts[12] != " ") ? lineParts[12] : " ";

                                Array.Clear(lineParts, 0, lineParts.Length);
                                return;
                            }
                           
                        }
                    }
                }
 
VS2022 is an IDE, when you choose Build Solution (or variations thereof) invokes the build engine which then invokes the compiler. In addition, the IDE's editor also invokes a subset of the compiler's parsing engine which generates the Intellisense errors and warnings.
 
When I take the individual file that I created and marry it up to the family file I will use it to give desired results in a web page. I know that this has been done before but I want to show where individuals were born to where thay died.
I would t bother transforming one file into another if I was later going to generate a web page, I'd be loading it into a database I could query by individual Id to quickly get back a list of relevant results about individuals and relatives
 
Back
Top Bottom