zoukankan      html  css  js  c++  java
  • StringSplitOptions

    string text = @"A better activation model is to allocate an object for a client only while a call is in
    progress from the client to the service. That way, you have to create and maintain only as many
    objects in memory as there are concurrent calls, not as many objects as there are outstanding
    clients. Between calls, the client holds a reference on a proxy that doesn't have an actual object
    at the end of the wire. The obvious benefit is that you can now dispose of the expensive resources
    the service instance occupies long before the client disposes of the proxy. By that same token,
    acquiring the resources is postponed until they are actually needed by a client. The second benefit
    is that forcing the service instance to reallocate or connect to its resources on every call caters
    very well to transactional resources and transactional programming because it eases the task of
    enforcing consistency with the instance state.";

    string matches = "of";//要查询的单词
    //按句子转换成数组
    string[] sentences = text.Split(new char[] { '.','?','!'});
    //使用LINQ找出所有包含of的句子
    var query = from item in sentences
                       //将句子按单词转换成数组
                      let words = item.Split(new char[]{'.','?','!',' ',';',':',','},
                                       StringSplitOptions.RemoveEmptyEntries)
                      //判断当前句子的单词中是否包含of
                      where words.Contains(matches)
                      select item;
    //显示查询结果
    foreach( var item in query)
    {
    Response.Write(item.ToString()+"<br/>");
    }

  • 相关阅读:
    Python学习Day2笔记(字符编码和函数)
    Python学习Day2笔记(集合和文件操作)
    PyCharm3.0默认快捷键(翻译的)
    C# 读取EXCEL文件的三种经典方法
    DataGridView列的宽度、行的高度自动调整
    禁用datagridview中的自动排序功能
    如何删除datatable中的一行数据
    NPOI导出Excel合并表头写入公式
    C# SaveFileDialog的用法(转载)
    linux操作
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/2867534.html
Copyright © 2011-2022 走看看