代码拉取完成,页面将自动刷新
using System;
namespace LearnCSharp_1
{
class LearnString
{
static void Main_String(string[] args)
{
Console.WriteLine("Hello World!");
Console.ReadKey();
string aFriend = "Bill";
Console.WriteLine("Hello " + aFriend);
Console.ReadKey();
Console.WriteLine($"Hello {aFriend}");
Console.ReadKey();
string firstFriend = "Maria";
string secondFriend = "Sage";
Console.WriteLine($"The name {firstFriend} has {firstFriend.Length} letters.");
Console.WriteLine($"The name {secondFriend} has {secondFriend.Length} letters.");
Console.ReadKey();
string greeting = " Hello world! ";
Console.WriteLine($"[{greeting}]");
string trimmedGreeting = greeting.TrimStart();
Console.WriteLine($"[{trimmedGreeting}]");
trimmedGreeting = greeting.TrimEnd();
Console.WriteLine($"[{trimmedGreeting}]");
trimmedGreeting = greeting.Trim();
Console.WriteLine($"[{trimmedGreeting}]");
Console.ReadKey();
string sayHello = "Hello World";
Console.WriteLine(sayHello);
sayHello = sayHello.Replace("Hello", "Greetings");
Console.WriteLine(sayHello);
Console.ReadKey();
Console.WriteLine(sayHello.ToUpper());
Console.WriteLine(sayHello.ToLower());
Console.ReadLine();
string songLyrics = "You say goodbye, and I say hello";
Console.WriteLine(songLyrics.Contains("goodbye"));
Console.WriteLine(songLyrics.Contains("greetings"));
Console.ReadKey();
Console.WriteLine(songLyrics.EndsWith("hello"));
Console.WriteLine(songLyrics.EndsWith("goodbye"));
Console.ReadKey();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。