C#获取字符串的长度
1、创建新项目

2、创建控制台应用程序

3、获取字符串的长度

4、完整代码
using System;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
//C#获取字符串的长度
//创建变量
string aa = "Maria";
//创建变量
string secondFriend = "Sage";
//多个变量,使用大括号,也能展示
// Console.WriteLine($"My friends are {aa} and {secondFriend}");
//Length 得出字符串的长度
Console.WriteLine($"The name {aa} has {aa.Length} letters.");
Console.WriteLine($"The name {secondFriend} has {secondFriend.Length} letters.");
}
}
}

5、运行,预览

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:195
阅读量:136
阅读量:20
阅读量:196
阅读量:92