Skip to content

Commit

Permalink
Make additional tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofmmm committed Jan 9, 2024
1 parent c5f2d8e commit 27eb1c9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions csharp-fundamentals-strings.Main/Extension.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text;

namespace csharp_fundamentals_strings.Main
{
Expand Down Expand Up @@ -43,11 +39,11 @@ public StringBuilder one()
// 1. Using the sb variable above, add "Hello, world!" to the StringBuilder
// WRITE YOUR CODE BETWEEN THIS LINE...


sb.Append("Hello, world!");
return sb;

// ...AND THIS LINE

return sb;
}

public StringBuilder two()
Expand All @@ -58,11 +54,13 @@ public StringBuilder two()
// 2. After adding the message, use an appropriate StringBuilder method to reverse it
// WRITE YOUR CODE BETWEEN THIS LINE...


sb.Append("Hello, world!");
char[] charArray = sb.ToString().ToCharArray();
Array.Reverse(charArray);
return new StringBuilder(new string(charArray));

// ...AND THIS LINE

return sb;
}

public StringBuilder three()
Expand All @@ -73,7 +71,12 @@ public StringBuilder three()
// 2. After adding the message, remove the comma.
// WRITE YOUR CODE BETWEEN THIS LINE...


sb.Append("Hello, world!");
int index = sb.ToString().IndexOf(",");
if(index >= 0)
{
sb.Remove(index , 1);
}

// ...AND THIS LINE

Expand All @@ -88,11 +91,11 @@ public StringBuilder four()
// 2. After adding the message, replace the word "world" with the word "C#"
// WRITE YOUR CODE BETWEEN THIS LINE...


sb.Append("Hello, world!");
return sb.Replace("world" , "C#");

// ...AND THIS LINE

return sb;
}
}
}

0 comments on commit 27eb1c9

Please sign in to comment.