Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.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# 如何使用嵌套类列对arraylist进行排序?_C#_Asp.net_Asp.net Mvc_Linq_Linq To Objects - Fatal编程技术网

C# 如何使用嵌套类列对arraylist进行排序?

C# 如何使用嵌套类列对arraylist进行排序?,c#,asp.net,asp.net-mvc,linq,linq-to-objects,C#,Asp.net,Asp.net Mvc,Linq,Linq To Objects,我有下面的代码显示。我想得到一个按每个单词排序的列表,显示“s”段中的时间。最后一个列表假设orderbydescending“times” void Main() { 字符串s="使用Thread类可以在System.Threading命名空间中找到Thread类。该类使您能够创建新踏板、管理其优先级并获取其状态。Thread类不应在应用程序中使用,除非您有特殊需要。但是,当使用Thread类时,您可以控制它所有配置选项。例如,您可以指定线程的优先级,告诉Windows您的线程正在长时间运行,

我有下面的代码显示。我想得到一个按每个单词排序的列表,显示“s”段中的时间。最后一个列表假设orderbydescending“times”

void Main()
{
字符串s="使用Thread类可以在System.Threading命名空间中找到Thread类。该类使您能够创建新踏板、管理其优先级并获取其状态。Thread类不应在应用程序中使用,除非您有特殊需要。但是,当使用Thread类时,您可以控制它所有配置选项。例如,您可以指定线程的优先级,告诉Windows您的线程正在长时间运行,或配置其他高级选项。清单1-1显示了使用thread类在另一个线程上运行方法的示例。Console类为您同步输出流的使用,以便您可以写入它来自多个线程。同步是一种确保两个线程不会同时执行程序特定部分的机制。对于控制台应用程序,这意味着没有两个线程可以同时向屏幕写入数据。如果一个线程正在处理输出流,则其他线程将无法执行“我必须等它完成。”;
变量a=s.Split(新字符[]{',',',',''''/','?',':',';','\','\','\',''.''''.','.''''.'','.'''.','.''.','.'.','.',''.','.'.','.'、'.'.'.'.'''''.'''''''.'''''.'、'.'.'''''.''''.'''''''.'.''''.'.'''''.'.''''.''''.'';
var q1=a.Where(o=>!o.IsEmpty());
var q2=q1.Distinct();
var al=新的ArrayList();
foreach(第二季度的var w)
{
al.Add(新结果{times=GetTimes(q1,w),word=w});
}
al.Dump();
}
public Func GetTimes=(arg1,arg2)=>
{
var rst=arg1.Count(o=>o==arg2);
返回rst;
};
公开课成绩
{
公共整数倍{get;set;}
公共字符串字{get;set;}
}

看来,你想要这样的东西

string s = "Using the Thread class The Thread class can be found in the System.Threading namespace. This class enables you to create new treads, manage their priority, and get their status. The Thread class isn’t something that you should use in your applications, except when you have special needs. However, when using the Thread class you have control over all configuration options. You can, for example, specify the priority of your thread, tell Windows that your thread is long running, or configure other advanced options. Listing 1-1 shows an example of using the Thread class to run a method on another thread. The Console class synchronizes the use of the output stream for you so you can write to it from multiple threads. Synchronization is the mechanism of ensuring that two threads don’t execute a specific portion of your program at the same time. In the case of a console application, this means that no two threads can write data to the screen at the exact same time. If one thread is working with the output stream, other threads will have to wait before it’s finished.";

var a = s.Split(" ,<.>/?:;\"'\\|{[}]`~!@#$%^&*()-_+=".ToCharArray(), 
                StringSplitOptions.RemoveEmptyEntries);

var list = a.Distinct()
            .Select(x => new result { times = a.Count(y => y == x), word = x })
            .OrderByDescending(x => x.times)
            .ToList();
字符串s=“使用Thread类,可以在System.Threading命名空间中找到Thread类。此类使您能够创建新踏板、管理其优先级并获取其状态。Thread类不应该在应用程序中使用,除非您有特殊需要。但是,当使用Thread类时,您可以控制所有配置选项。例如,您可以指定线程的优先级,告诉Windows您的线程正在长时间运行,或者配置其他高级选项。清单1-1显示了使用Thread类在另一个线程上运行方法的示例。Console类为您同步输出流的使用,以便您可以从多个线程对其进行写入。同步是确保两个线程不同时执行程序特定部分的机制。对于控制台应用程序,这意味着没有两个线程可以同时向屏幕写入数据。如果一个线程正在处理输出流,则其他线程必须等待它完成。“;
var a=s.Split(“,/?:;\”'\\\\\\{[}]`~!@$%^&*()-\+=”.ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
var list=a.Distinct()
.Select(x=>newresult{times=a.Count(y=>y==x),word=x})
.OrderByDescending(x=>x.times)
.ToList();
请仔细阅读以下内容:
string s = "Using the Thread class The Thread class can be found in the System.Threading namespace. This class enables you to create new treads, manage their priority, and get their status. The Thread class isn’t something that you should use in your applications, except when you have special needs. However, when using the Thread class you have control over all configuration options. You can, for example, specify the priority of your thread, tell Windows that your thread is long running, or configure other advanced options. Listing 1-1 shows an example of using the Thread class to run a method on another thread. The Console class synchronizes the use of the output stream for you so you can write to it from multiple threads. Synchronization is the mechanism of ensuring that two threads don’t execute a specific portion of your program at the same time. In the case of a console application, this means that no two threads can write data to the screen at the exact same time. If one thread is working with the output stream, other threads will have to wait before it’s finished.";

var a = s.Split(" ,<.>/?:;\"'\\|{[}]`~!@#$%^&*()-_+=".ToCharArray(), 
                StringSplitOptions.RemoveEmptyEntries);

var list = a.Distinct()
            .Select(x => new result { times = a.Count(y => y == x), word = x })
            .OrderByDescending(x => x.times)
            .ToList();