Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions csharp/events/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Program
{
static void Main(string[] args)
{
var lister = new FileSearcher();
var fileLister = new FileSearcher();
int filesFound = 0;

// <SnippetDeclareEventHandler>
Expand All @@ -22,21 +22,21 @@ static void Main(string[] args)
filesFound++;
};

lister.FileFound += onFileFound;
fileLister.FileFound += onFileFound;
// </SnippetDeclareEventHandler>

// <SnippetSearch>
lister.DirectoryChanged += (sender, eventArgs) =>
fileLister.DirectoryChanged += (sender, eventArgs) =>
{
Console.Write($"Entering '{eventArgs.CurrentSearchDirectory}'.");
Console.WriteLine($" {eventArgs.CompletedDirs} of {eventArgs.TotalDirs} completed...");
};
// </SnippetSearch>

lister.Search(".", "*.dll", true);
fileLister.Search(".", "*.dll", true);

// <SnippetRemoveHandler>
lister.FileFound -= onFileFound;
fileLister.FileFound -= onFileFound;
// </SnippetRemoveHandler>
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void ShowCurrency()
// current culture is English (United States):
// $12,345.68
// $12,345.679
// kr 12.345,679
// 12.345,679 kr
// </Snippet1>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Example
{
static void Main(string[] args)
{
// <SnippetRoundTrip>
Console.WriteLine("Attempting to round-trip a Double with 'R':");
double initialValue = 0.6822871999174;
string valueString = initialValue.ToString("R",
Expand All @@ -22,13 +23,14 @@ static void Main(string[] args)
CultureInfo.InvariantCulture);
Console.WriteLine("{0:R} = {1:R}: {2}\n",
initialValue, roundTripped17, initialValue.Equals(roundTripped17));
// If compiled to an application that targets anycpu or x64 and run on an x64 system,
// the example displays the following output:
// Attempting to round-trip a Double with 'R':
// 0.6822871999174 = 0.68228719991740006: False
//
// Attempting to round-trip a Double with 'G17':
// 0.6822871999174 = 0.6822871999174: True
// </SnippetRoundTrip>
}
}
// If compiled to an application that targets anycpu or x64 and run on an x64 system,
// the example displays the following output:
// Attempting to round-trip a Double with 'R':
// 0.6822871999174 = 0.68228719991740006: False
//
// Attempting to round-trip a Double with 'G17':
// 0.6822871999174 = 0.6822871999174: True
// </Snippet5>
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public class NumericFormats
{
public static void Main()
{
// <SnippetFinalExample>
// Display string representations of numbers for en-us culture
CultureInfo ci = new CultureInfo("en-us");

Expand Down Expand Up @@ -216,6 +217,7 @@ public static void Main()
Console.WriteLine("X: 0x{0}",
integral.ToString("X", ci)); // Displays "X: 0x20CB"
Console.WriteLine();
// </SnippetFinalExample>
}
}
// </Snippet1>
Expand Down
5 changes: 5 additions & 0 deletions snippets/standard/base-types/format-strings/csharp/g17.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class Example
{
public static void Main()
{
// <SnippetGeneralFormatSpecifier>
double original = 0.84551240822557006;
var rSpecifier = original.ToString("R");
var g17Specifier = original.ToString("G17");
Expand All @@ -13,6 +14,10 @@ public static void Main()

Console.WriteLine($"{original:G17} = {rSpecifier} (R): {original.Equals(rValue)}");
Console.WriteLine($"{original:G17} = {g17Specifier} (G17): {original.Equals(g17Value)}");
// The example displays the following output:
// 0.84551240822557006 = 0.84551240822557: False
// 0.84551240822557006 = 0.84551240822557006: True
// </SnippetGeneralFormatSpecifier>
}
}
// The example displays the following output:
Expand Down