Alecu
Alecu

Reputation: 2708

What's the best way to pass specific parameters to a method

I am writing a C# components that gathers information from the input parameters and returns the gathered information in a dictionary like this : Dictionary. The current method signature looks like this:

public Dictionary<string, object> GenerateAliquotLabel(EAliquoteLabelOptions fieldsToAdd, AliquoteLabelGeneratorParameters parameters)

The parameters parameter contains all the sources from which information is returned. The keys in the dictionary that I return are currently generated internally.

The problem is that now I want to specify the keys in the dictionary that I return as parameters and I do not know any elegant ways to do this.

Upvotes: 0

Views: 45

Answers (1)

Ingwar
Ingwar

Reputation: 100

If I understand you correctly, your option is params.

public Dictionary<string, object> GenerateAliquotLabel(params string[] parameters);

Then you can use that method similar to String.Format() for example:

var output = Generator.GenerateAliquotLabel("BlueLabel", "RedLabel", "SmallLabel");

Upvotes: 1

Related Questions