I was writing a class with two diffrent constructor overloads:
var rawItems = mongoItemsCollection
.Find(aggregateFilter)
.ToListAsync().Result;
After I wrote it, my code got me confused that how should I know that if the variable public class MyClass
{
public MyClass(params string[] Files)
{
}
public MyClass(string Path, params string[] Files)
{
}
}
is given as argument or not.
There is no error in program but I'm wondering for example if I run the following code, how to understand that Path
is given or not?
Path
it can be either
MyClass x = new Myclass("a","b","c");
or just
Path = "a";
Files = string[]{"b","c"};
答案 0 :(得分:0)
Try using named parameters:
MyFunction(parameter1: value1, parameter2: value2);