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

Changed String to string. IDE0049 #10384

Merged
merged 3 commits into from
Sep 13, 2024
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
4 changes: 4 additions & 0 deletions snippets/csharp/System/String/Replace/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//Example1.Main();
//Example2.Main();
//Example3.Main();
Example4.Main();
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>
8 changes: 4 additions & 4 deletions snippets/csharp/System/String/Replace/replace1.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;

public class Example
public class Example1
{
public static void Main()
{
// <Snippet1>
String s = "aaa";
Console.WriteLine("The initial string: '{0}'", s);
string s = "aaa";
Console.WriteLine($"The initial string: '{s}'");
s = s.Replace("a", "b").Replace("b", "c").Replace("c", "d");
Console.WriteLine("The final string: '{0}'", s);
Console.WriteLine($"The final string: '{s}'");

// The example displays the following output:
// The initial string: 'aaa'
Expand Down
8 changes: 4 additions & 4 deletions snippets/csharp/System/String/Replace/replace2.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;

public class Example
public class Example2
{
public static void Main()
{
// <Snippet2>
String s = new String('a', 3);
Console.WriteLine("The initial string: '{0}'", s);
string s = new('a', 3);
Console.WriteLine($"The initial string: '{s}'");
s = s.Replace('a', 'b').Replace('b', 'c').Replace('c', 'd');
Console.WriteLine("The final string: '{0}'", s);
Console.WriteLine($"The final string: '{s}'");

// The example displays the following output:
// The initial string: 'aaa'
Expand Down
12 changes: 7 additions & 5 deletions snippets/csharp/System/String/Replace/string.replace1.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;

class stringReplace1 {
public static void Main() {
class Example3
{
public static void Main()
{
//<snippet1>
String str = "1 2 3 4 5 6 7 8 9";
Console.WriteLine("Original string: \"{0}\"", str);
Console.WriteLine("CSV string: \"{0}\"", str.Replace(' ', ','));
string str = "1 2 3 4 5 6 7 8 9";
Console.WriteLine($"Original string: \"{str}\"");
Console.WriteLine($"CSV string: \"{str.Replace(' ', ',')}\"");

// This example produces the following output:
// Original string: "1 2 3 4 5 6 7 8 9"
Expand Down
9 changes: 3 additions & 6 deletions snippets/csharp/System/String/Replace/stringreplace.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
using System;

public class ReplaceTest
public class Example4
{
public static void Main()
{

//<snippet1>
string errString = "This docment uses 3 other docments to docment the docmentation";

Console.WriteLine("The original string is:{0}'{1}'{0}", Environment.NewLine, errString);
Console.WriteLine($"The original string is:{Environment.NewLine}'{errString}'{Environment.NewLine}");

// Correct the spelling of "document".

string correctString = errString.Replace("docment", "document");

Console.WriteLine("After correcting the string, the result is:{0}'{1}'",
Environment.NewLine, correctString);
Console.WriteLine($"After correcting the string, the result is:{Environment.NewLine}'{correctString}'");

// This code example produces the following output:
//
Expand Down