工作总结 string数组 排序 string数组 比较

用到 工具类 Array 创建、处理、搜索数组并对数组进行排序
Enumerable 提供一组用于查询实现 System.Collections.Generic.IEnumerable<T> 的对象的 static(在 Visual
// Basic 中为 Shared)方法。 实现了 IEnumerable<T>类 的

c# 比较两个数组每一个值是否相等
int[] a = new int[] { 1, 2, 4, 5 };
int[] b = new int[] { 1, 3, 4, 5 };
if (Enumerable.SequenceEqual(a,b))
{
label1.Text = "一样";
}
Enumerable.SequenceEqual(strs1,
strs2)
通过使用相同类型的默认相等比较器对序列元素进行比较,以确定两个序列是否相等。
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace demo1
{
static class Help
{
public static Guid TogGuid(this object value)
{
try
{
if (value == null) return Guid.Empty;
else
{
if (value == "") return Guid.Empty;
else return new Guid(value.ToString());
}
}
catch { return Guid.Empty; }
}
}
class Program
{
static void Main(string[] args)
{
;
decimal s2 = (decimal)0.2577;
decimal s3 = s / s2;
Console.WriteLine(s3);
//string s = "";
//string m = null;
//var ssd = s.TogGuid();
//var ssdss = m.TogGuid();
//Console.WriteLine(s.TogGuid());
//Console.WriteLine(m.TogGuid());
//object s =null;
//default(T);
Console.WriteLine(default(Guid));
Console.WriteLine(default(int));
Console.WriteLine(default(Nullable<int>));
Console.WriteLine(default(string));
Console.WriteLine(default(object));
string a = "01,02,05,03,00";
string b = "01,02,05,00";
string[] aa = a.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
string[] bb = b.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
//aa = b.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
Array.Sort(aa);
Array.Sort(bb);
Console.WriteLine(Enumerable.SequenceEqual(aa, bb));
//IEnumerable
, , };
//asdasp.Contains() IEnumerable<TSource> 支持的
Console.WriteLine(asdasp.Sum()); // 每个数组都实现了IEnumerable<T> 所以可以使用 IEnumerable<T> 的扩展方法 (static class Enumerable 中)
// Enumerable static class IEnumerable<T> 工具类
//所以 Enumerable.SequenceEqual 支持 int 的数组
//Enumerable类 工具类 提供一组用于查询实现 System.Collections.Generic.IEnumerable<T> 的对象的 static(在 Visual
// Basic 中为 Shared)方法。
//asdasp.SequenceEqual() 这样也支持的
//扩展方法的另一种写法
, , };
asdasp.SequenceEqual(asdasp2);
Enumerable.SequenceEqual(asdasp, asdasp2);
//string[] b = { "", "", "", "", "", "" };
//其他的也一样 通过使用默认的相等比较器确定序列是否包含指定的元素。
// public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value);
asdasp2.Contains(); // 对象点 的方式 就需要写一个参数
Enumerable.Contains(asdasp2, ); // 静态类点 的方式 就需要写两个参数
}
}
}


效果一样
// 其实每个集合都实现了 IEnumerable<T> 集合 数组 都实现 IEnumerable<T> 所以可以使用 IEnumerable<T> 的扩展方法 (static class Enumerable 中)
// Enumerable static class IEnumerable<T> 工具类
工作总结 string数组 排序 string数组 比较的更多相关文章
- 6种字符串数组的java排序 (String array sort)
注意,本文不是字符串排序,是字符串数组的排序. 方法分别是: 1.低位优先键索引排序 2.高位优先建索引排序 3.Java自带排序(经过调优的归并排序) 4.冒泡排序 5.快速排序 6.三向快速排序 ...
- 使用泛型实现对int数组或者String数组进行排序
因为是使用的泛型,我们并不确定数据类型, 对于数据的比较就不能用平时的大于或者小于. 我们需要比较对象实现Comparable接口,该接口下的compareTo()方法可以用来比大小 定义Sort类: ...
- C#"曾经的字符串数组"string[] array=new string[]{"**","****"};
写博客是一件很伟大的事情,尤其是也牛逼的博客,因为它能帮助需要的人,更能使自己对知识有一个更为深刻的理解! 欢迎关注我的博客! 字符串操作(取当前时间) string time=convert.tos ...
- Swift3 - String 字符串、Array 数组、Dictionary 字典的使用
Swift相关知识,本随笔为 字符串.数组.字典的简单使用,有理解.使用错误的地方望能指正. ///************************************************** ...
- 条目十三《尽量使用vector和string来代替使用数组》
条目十三<尽量使用vector和string来代替使用数组> 数组在现代编程语言中基本都存在,应用可谓广泛,不可或缺,虽然在一些语言中(go)有切片等数据结构,但是数组还是存在的. 但是在 ...
- Java第二次作业——数组和String类
Java第二次作业--数组和String类 学习总结 1.学习使用Eclipse关联jdk源代码,查看String类的equals()方法,截图,并学习其实现方法.举例说明equals方法和==的区别 ...
- PChar,PAnsiChar,String,AnsiString,Char数组,AnsiChar数组转换
PChar,PAnsiChar,String,AnsiString,Char数组,AnsiChar数组之间的转换关系见下图 通过转换链,可以实现任意两个类型之间的互转.如PChar转PAnsiChar ...
- int数组转string数组和int数组转string中间用逗号隔开
//int 数组转string数组 ,,,}; string result=test.Select(i => i.ToString()).ToArray(); //int 数组转 string中 ...
- Unity3D 集成 Face++ FacePlusPlus httpClient http协议 byte数组转string
//開始由于要实现跨平台.考虑过用curl封装c++的dll(android *.so)的方式,在c#Dllimport实现 //后来发现Unity3D本身支持http协议.且face++的api都是 ...
随机推荐
- MyEclipse2017修改Web Context Root
1,复制一个已经存在的项目,并修改项目名 2,选中项目右键选择properities,打开. 但是这里的web context root无法修改 3,删除web显示properties的所有属性,输入 ...
- appendHTML方法ajax加载更多评论实例页面
//在后添加 <script>var appendHTML = function(el, html) { var divTemp = document.createElement(&quo ...
- 大项目之网上书城(九)——订单Demo
目录 大项目之网上书城(九)--订单Demo 主要改动 1.OrderServiceImpl 代码 2.OrderDaoImpl 代码 3.OrderitemDaoImpl 代码 4.orderite ...
- MySQL异常:Caused by: com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request
Caused by: com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or cl ...
- [Python3网络爬虫开发实战] 1.9.5-Scrapyrt的安装
Scrapyrt为Scrapy提供了一个调度的HTTP接口,有了它,我们就不需要再执行Scrapy命令而是通过请求一个HTTP接口来调度Scrapy任务了.Scrapyrt比Scrapyd更轻量,如果 ...
- prop 和 attr 中一些羞羞的事情
引言 前几天做一个迷你京东小项目的时候涉及到一个全选的小功能,一开始用的是 attr,但是效果完全不是自己想要的,当商品按钮点击过一次后,attr就无法对其状态进行更改,最后谷歌了一番发现需要用 pr ...
- eclipse中自动生成注释
eclipse中自动生成注释 包前缀设置的地方 注释模板设置的地方 Eclipse自动生成方法注释 快捷键 自动生成方法的注释格式,例如 /*** @param str* @return* @thro ...
- WebLoad 脚本的用法
WebLoad 对于模拟一个HTTP 请求,一般都是 由以下三部分组成,并把这三部分包在一个Transaction里(从BeginTransation 到 EndTransaction 为止): ...
- hdu 1828 Picture(线段树,扫描线)
A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wa ...
- 【Tomcat】tomcat启动后查看运行时JVM参数
Tomcat优化配置参考http://www.cnblogs.com/qlqwjy/p/8007490.html 1.启动服务后访问localhost,点击Server Status