这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
Closed
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
2 changes: 1 addition & 1 deletion Beginners/Methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Replace the *name* variable with a *names* variable that has a list of names. Th
Console.WriteLine($"Hello {name.ToUpper()}!");
}
```
#### Previous - [Strings & Variables «](./Strings.md) Home - [Home](../README.md)
#### Next: [Coding challenge »](./Challenge.md) Previous - [Strings & Variables «](./Strings.md) Home - [Home](../README.md)
8 changes: 8 additions & 0 deletions Beginners/challenge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Try it yourself

The code block on this page has an empty method for your to fill in. Write code that removes all the vowels from a `string`. One of the methods you can use with string is `Replace`. That method replaces a set of characters in a string with a replacement. If the replacement string is the empty string (Two quotes with no characters between them: ""), that removes the characters.

``` cs --region challenge --source-file .\myapp\Program.cs --project .\myapp\myapp.csproj
```

#### Previous - [Methods «](./Methods.md) Home - [Home](../README.md)
46 changes: 45 additions & 1 deletion Beginners/myapp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;
using System.Linq;
namespace myapp
Expand Down Expand Up @@ -31,6 +32,9 @@ static void Main(string region = null,
case "collections":
Collections();
break;
case "challenge":
TestChallengeCode();
break;
case "handcoded":
PascalsTriangle.HardCoded();
break;
Expand Down Expand Up @@ -90,6 +94,46 @@ public static void Collections()
#endregion
}

public static void TestChallengeCode()
{
(string arg, string result)[] inputs =
{
("Hello World!","Hll Wrld!"),
("Here's a simple sentence.", "Hr's smpl sntnc."),
("You've learned to manipulate strings in C#. Well Done!" ,"Y'v lrnd t mnplt strngs n C#. Wll Dn!")
};

bool allCorrect = true;
foreach (var item in inputs)
{
var r = RemoveVowels(item.arg);

if (r == item.result)
Console.WriteLine($"Correct! {item.arg} => {r}");
else
{
Console.WriteLine($"Try again: {item.arg} !=> {r}");
allCorrect = false;
}
Console.WriteLine();
}
if (allCorrect)
Console.WriteLine("Congratulations! You solved this challenge!");
else
Console.WriteLine("Not quite right yet. Try again.");
}

#region challenge
public static string RemoveVowels(string inputText)
{
// Fill in this code and create a string
// that removes all the vowels from the input string.
// Remember that vowels are 'a', 'e', 'i', 'o' and 'u'.
// Remember to remove both upper and lower case.
return inputText;
}
#endregion

public static void PascalsTriangleHardCoded()
{
#region handcoded
Expand Down
11 changes: 11 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"sdk": {
"version": "3.0.100-preview6-012264"
},
"tools": {
"dotnet": "3.0.100-preview6-012264"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19257.7"
}
}