-3

Newb to C# and OOP. My journey thus far has been to take code bases that I've inherited from former developers and either address issues, or add enhancements, whilst trying to understand said code bases' structures from front-to-back.

I'm having trouble fully grasping the concept around the parameters which follow the initial declaration of a method. Here's an example of a method I'm working with:

public List<Entity> ParseCsvFile(List<string> entries, string urlFile)
    {
      entries.RemoveAt(entries.Count - 1);
      entries.RemoveAt(0);
      List<Entity> entities = new List<Entity>();

      foreach (string line in entries)
      {
        Entity entityManagement = new Entity();
        string[] lineParts = line.Split('|');
        entityManagement.Identifier = lineParts[0];
        entityManagement.ProductId = 1234;
        entityManagement.Category = "ABCDE";
        entities.Add(entityManagement);
      }
      return entities;
    }

The part after ParseCsvFile in parentheses: (List<string> entries, string urlFile) Could someone explain what these are and what they do, perhaps with metaphors/analogies/real-world examples?

7

1 Answer 1

3

It might be easier to see their purpose if you look at a simpler function for example:

public int Add(int number1, int number2)
{
    return number1 + number 2;
}

Above there is a function that adds two numbers together and returns the result. It is a set of instructions to follow. How can it follow the instructions if it doesn't know what numbers to use. That's where calling the function comes in. for example:

var result = Add(2, 5);

In this scenario result = 7.

2 is replacing number1 in the function and 5 is replacing number2.

1
  • Thank you, Jack. That makes perfect sense. All it takes is someone who's willing to help.
    – Stpete111
    Oct 2, 2019 at 13:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.