I am converting a large VB.Net project to C#. I used an free automated tool to convert them. VB is happy with empty parameters passed in and uses default values for them supplied in the method definition.
After the conversion, there are many calls in the C# code looking like this:
GetElement(ndFirst, WAIT_AFTER_BATCH,false, , , "WAIT");
And compiler is not happy…
Can someone point me in the right direction if I can edit the C# files automatically(since intellisense knows how to) to fill these default values when I am making the call.
I am assuming that the C# version of your methods has the default parameters specified correctly, ex.
If you want to call the method and accept the default for paramB (as in your example), then you need to name the parameters
This would collect values for paramA and paramC whilst using the default for paramB.
Furthermore, since paramA is in the correct position, this will also be correct
Alternatively, if the parameter you want to leave out is the last one, you can simply leave it out and call your method like so
Where paramA = 12, paramB = 20 and paramC will use the default of 2.
Unfortunately I am unaware of an automatic way to fix these. Likewise, to speed you up, you can use ReSharper and create a formatter to enforce using named arguments. Then run a simple regex over your project and clean out any instances of ‘,,’
Note I am in no way affiliated with JetBrains or ReSharper. I am a mere client of this company.