Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better integration of Option<T> with string formatting #20

Open
atifaziz opened this issue Dec 23, 2016 · 0 comments
Open

Better integration of Option<T> with string formatting #20

atifaziz opened this issue Dec 23, 2016 · 0 comments

Comments

@atifaziz
Copy link
Contributor

This is a follow-on issue from #17.

If #19 is merged then the issue of formatting still remains; that is, the following:

var d = new DateTime(2010, 12, 31).Some();
var s = string.Format(new CultureInfo("de-DE"), "{0:D}", d);
Console.WriteLine(s);

will print:

31/12/2010 00:00:00

This is better than printing Some(31/12/2010 00:00:00) but not the expected value of Freitag, 31. Dezember 2010.

Option<T> could be made to integrate better with string formatting by making it implement IFormattable and then format the value (when Some) using the format and IFormatProvider passed to IFormattable.ToString().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant