Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions snippets/csharp/System/String/Replace/Project.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion snippets/csharp/System/String/Replace/replace1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class Example
public static void Main()
{
// <Snippet1>
String s = "aaa";
string s = "aaa";
Console.WriteLine("The initial string: '{0}'", s);
s = s.Replace("a", "b").Replace("b", "c").Replace("c", "d");
Console.WriteLine("The final string: '{0}'", s);
Expand Down
2 changes: 1 addition & 1 deletion snippets/csharp/System/String/Replace/replace2.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;

public class Example

Check failure on line 3 in snippets/csharp/System/String/Replace/replace2.cs

View workflow job for this annotation

GitHub Actions / snippets-build

D:\a\dotnet-api-docs\dotnet-api-docs\snippets\csharp\System\String\Replace\replace2.cs(3,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'Example' [D:\a\dotnet-api-docs\dotnet-api-docs\snippets\csharp\System\String\Replace\Project.csproj]
{
public static void Main()

Check failure on line 5 in snippets/csharp/System/String/Replace/replace2.cs

View workflow job for this annotation

GitHub Actions / snippets-build

D:\a\dotnet-api-docs\dotnet-api-docs\snippets\csharp\System\String\Replace\replace2.cs(5,24): error CS0111: Type 'Example' already defines a member called 'Main' with the same parameter types [D:\a\dotnet-api-docs\dotnet-api-docs\snippets\csharp\System\String\Replace\Project.csproj]
{
// <Snippet2>
String s = new String('a', 3);
string s = new String('a', 3);
Console.WriteLine("The initial string: '{0}'", s);
s = s.Replace('a', 'b').Replace('b', 'c').Replace('c', 'd');
Console.WriteLine("The final string: '{0}'", s);
Expand Down
2 changes: 1 addition & 1 deletion snippets/csharp/System/String/Replace/string.replace1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class stringReplace1 {
public static void Main() {
//<snippet1>
String str = "1 2 3 4 5 6 7 8 9";
string str = "1 2 3 4 5 6 7 8 9";
Console.WriteLine("Original string: \"{0}\"", str);
Console.WriteLine("CSV string: \"{0}\"", str.Replace(' ', ','));

Expand Down
Loading