using DocumentFormat.OpenXml.Drawing.Charts;
using System;
using System.Collections.Generic;
using System.Text;
namespace KnowledgePoint
{
class _36_Ex_Function
{
static void Main(string[] args)
{
string[] NBA = { "张伯伦", "比尔·拉塞尔", "朱利叶斯·欧文", "拉里·伯德", "伊塞亚·托马斯", "“魔术师”约翰逊", "艾伦·艾弗森", "科比·布莱恩特", "凯文·加内特", "邓肯/奥尼尔" };
string NBA_star = TheLongestName(NBA);
Console.WriteLine("NBA明星球员队伍最长姓名:" + NBA_star);
Console.ReadKey();
}
private static string TheLongestName(string[] array)
{
string longest = array[0];
for (int i = 0; i < array.Length; i++)
{
if (array[i].Length > longest.Length)
{
longest = array[i];
}
}
return longest;
}
}
}
C#找出字符串数组中最长的元素
最新推荐文章于 2024-04-15 15:51:09 发布