Parameter object becomes null after being passed to function

AOY

I'm new to c#. I'm trying to send a list item as a parameter of a function. Before the moment it is passed the item exists. But inside the function it appears to be null. I would be grateful if anyone could explain me my mistake.

    List<HSCodeData> HSCodeDataList;

    internal void buildHSCodeDocument(List<HSCodeData> initHSCodeDataList)
    {
        HSCodeDataList = initHSCodeDataList;           

        foreach (HSCodeData dataItem in HSCodeDataList)
        {
            if ((dataItem != null)&&(dataItem.HSCode!=""))
            {
                string descriptionString = BuildDescriptionString(dataItem);
                dataItem.ParentHSCode = descriptionString;
            }                 
        }
    }

    internal string BuildDescriptionString(HSCodeData HSCodeDataItem)
    {
        string descriptionString = HSCodeDataItem.Description + ItemSuggestedDescription(HSCodeDataItem);
        if ((ItemHasParent(HSCodeDataItem.ParentHSCode)) && (HSCodeDataList != null) && (HSCodeDataList.Count != 0))
        {
            descriptionString += BuildDescriptionString(findParentItem(HSCodeDataItem.ParentHSCode));
        }
        return descriptionString;
    }
Henrik

In buildHSCodeDocument there is no way the argument passed to BuildDescriptionString could be null. But there is a recursive call to BuildDescriptionString where the return value of findParentItem is passed. Probably findParentItem returns null.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

IWebElement becomes null after being sent to a function

From Dev

Object becomes null outside of callback function

From Dev

Passed object not treated as the first parameter of function in javascript

From Dev

Checking if a parameter passed to a member function is the object itself

From Dev

Variable changes after being used as function parameter

From Dev

If final object is being passed, should null still be checked?

From Dev

Object is null after being initialized in a method

From Dev

Object becomes null

From Dev

C pointer does not get set after being passed to a function

From Dev

Changing a Labels value in Javascript after being passed into a function

From Dev

Retrieve Id of object being passed from call function

From Java

null being assigned as object in tail recursive function

From Dev

Rails parameter not being passed on post

From Dev

Empty string becomes null when passed from Delphi to C# as a function argument

From Dev

ViewModel becomes null when passed between actions

From Dev

CoffeeScript callback parameter becomes Object

From Dev

Invalid length parameter passed to the LEFT or SUBSTRING function with null values

From Dev

Bundle being passed to Fragment is null?

From Dev

How do I access object parameter passed in a function using javascript?

From Dev

How can I tell if a parameter passed to a function is an object or a string?

From Dev

Calling a function passed as parameter

From Dev

Lambda function passed as parameter

From Dev

Game becomes unresponsive after being added to a JFrame

From Dev

How to distinct between (object)null and (decimal?)null when passed in object parameter?

From Dev

How to distinct between (object)null and (decimal?)null when passed in object parameter?

From Dev

How to prevent a list from changing after being used as parameter in function?

From Dev

Array not being passed to Function Method

From Dev

What is being passed into this 'function(x)'?

From Dev

What is the meaning of the fat arrow syntax when being passed as a parameter in a function call?

Related Related

  1. 1

    IWebElement becomes null after being sent to a function

  2. 2

    Object becomes null outside of callback function

  3. 3

    Passed object not treated as the first parameter of function in javascript

  4. 4

    Checking if a parameter passed to a member function is the object itself

  5. 5

    Variable changes after being used as function parameter

  6. 6

    If final object is being passed, should null still be checked?

  7. 7

    Object is null after being initialized in a method

  8. 8

    Object becomes null

  9. 9

    C pointer does not get set after being passed to a function

  10. 10

    Changing a Labels value in Javascript after being passed into a function

  11. 11

    Retrieve Id of object being passed from call function

  12. 12

    null being assigned as object in tail recursive function

  13. 13

    Rails parameter not being passed on post

  14. 14

    Empty string becomes null when passed from Delphi to C# as a function argument

  15. 15

    ViewModel becomes null when passed between actions

  16. 16

    CoffeeScript callback parameter becomes Object

  17. 17

    Invalid length parameter passed to the LEFT or SUBSTRING function with null values

  18. 18

    Bundle being passed to Fragment is null?

  19. 19

    How do I access object parameter passed in a function using javascript?

  20. 20

    How can I tell if a parameter passed to a function is an object or a string?

  21. 21

    Calling a function passed as parameter

  22. 22

    Lambda function passed as parameter

  23. 23

    Game becomes unresponsive after being added to a JFrame

  24. 24

    How to distinct between (object)null and (decimal?)null when passed in object parameter?

  25. 25

    How to distinct between (object)null and (decimal?)null when passed in object parameter?

  26. 26

    How to prevent a list from changing after being used as parameter in function?

  27. 27

    Array not being passed to Function Method

  28. 28

    What is being passed into this 'function(x)'?

  29. 29

    What is the meaning of the fat arrow syntax when being passed as a parameter in a function call?

HotTag

Archive