NET 4.0 C# new argument feature.

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I know that in NET 4 instead of using:

public int method(string p1) {};
public int method(string p1, string p2) {};

I can use simply:
public int method(string p1, string p2 = "") {};

But it seems I can't use the following:
public int method(DateTime dt1, DayOfWeek eFirstDayOfWeek =
DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek)

It seems the default values must be only "", int, etc.

Maybe I am looking at this the wrong way but it does not make a lot of
sense ... Does it?

Thanks,
Miguel
 
Hi,

The optional argument needs to be a constant.

You could pass a DateTimeFormatInfo and use null as the default value in
which case you'll be able to use DateTimeFormatInfo.CurrentInfo instead...

--
Patrice

"shapper" <[email protected]> a écrit dans le message de groupe de
discussion :
(e-mail address removed)...
 
Back
Top