add Programmyday form github
This commit is contained in:
10
ExtensionMethods/ExtensionMethods.csproj
Normal file
10
ExtensionMethods/ExtensionMethods.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
27
ExtensionMethods/Program.cs
Normal file
27
ExtensionMethods/Program.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Text;
|
||||
|
||||
namespace ExtensionMethods
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string text = "Abra Kadabra";
|
||||
Console.WriteLine(text);
|
||||
Console.WriteLine(text.SwitchCase());
|
||||
}
|
||||
}
|
||||
static class StringExtensions
|
||||
{
|
||||
public static string SwitchCase(this string s)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (char c in s)
|
||||
{
|
||||
sb.Append(char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user