Skip to content

Conversation

WilliamAntonRohm
Copy link
Contributor

@WilliamAntonRohm WilliamAntonRohm commented Dec 31, 2019


public class Example
{
public static void Main()
{
// <Snippet1>
decimal[] decimals = { Decimal.MaxValue, 12.45M, 0M, -19.69M,
Decimal.MinValue };
foreach (decimal value in decimals)
Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may check if there are other places where string interpolation can be used.

Suggested change
Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value));
Console.WriteLine($"Abs({value}) = {Math.Abs(value)}");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This set of changes is optional, but highly recommended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This instance is fixed -- looking for others now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BillWagner, @Youssef1313 -- there are 13 more such constructs in this set of example files; working on them.

Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing all this work @WilliamAntonRohm

I've added a couple comments that we should address before merging this one.


public class Example
{
public static void Main()
{
// <Snippet1>
decimal[] decimals = { Decimal.MaxValue, 12.45M, 0M, -19.69M,
Decimal.MinValue };
foreach (decimal value in decimals)
Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This set of changes is optional, but highly recommended.

Copy link
Contributor Author

@WilliamAntonRohm WilliamAntonRohm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(not sure why GitHub started a review on my behalf)

@WilliamAntonRohm
Copy link
Contributor Author

@BillWagner, @Youssef1313 -- I've updated 11 of the 13 remaining occurrences. Those two seem simpler as-is:

max.cs

string str = "{0}: The greater of {1,3} and {2,3} is {3}.";
...
Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Max(xByte1, xByte2));
Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Max(xShort1, xShort2));
Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Max(xInt1, xInt2));
...

min.cs likewise.

@BillWagner BillWagner merged commit 316b3ca into dotnet:master Jan 3, 2020
AaronRobinsonMSFT pushed a commit to AaronRobinsonMSFT/samples that referenced this pull request Apr 30, 2020
I added an additional "Jody" per issue dotnet/dotnet-api-docs#1875 to demonstrate how the sorting function handles duplicate values, and updated the sample unsorted and sorted output to demonstrate how the duplication is handled.
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

Successfully merging this pull request may close these issues.

3 participants