Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 哪个句子最大,包含多少个数字_C# - Fatal编程技术网

C# 哪个句子最大,包含多少个数字

C# 哪个句子最大,包含多少个数字,c#,C#,你就快到了。如果使用System.Linq命名空间,这是最简单的: using System; namespace MyCSharpLearning { class StringProject { public int LargestSentenceInformation(string i) { string[] txt = i.Split(new char[] { '.', '?', '!', ',' });

你就快到了。如果使用System.Linq命名空间,这是最简单的:

using System;
namespace MyCSharpLearning
{
    class StringProject
    {
       public int LargestSentenceInformation(string i)
       {
           string[] txt = i.Split(new char[] { '.', '?', '!', ',' });
           var largeS=txt.Order          
       }
       public static void Main(string[] args)
        {
           StringProject n = new StringProject();
           string str1 = Console.ReadLine();           
           Console.ReadLine();
        }
    }
}

stringsorderedByLargest现在将包含从最长到最短的排序。如果要计算一个字符串的字数,只需进行另一次拆分,但这次是在“”上,并查看结果集合的count属性。

请询问相关问题格式化。。。。。感谢所有正在编辑的人。我是C编程新手。我想知道如何写代码哪个句子最大,包含多少个单词。不清楚你在问什么。你的代码没有解释你想做什么这听起来很像是某人的编程作业向我提出的问题。。。
string[] txt = i.Split(new char[] { '.', '?', '!', ',' }); //this part you had correct
var stringsOrderedByLargest = txt.OrderByDescending(s => s.length);