What Is (and What Isn’t) in Our Array?
来源:互联网 发布:算法时代txt 编辑:程序博客网 时间:2024/05/18 14:42
复习一下数组里面查找元素等一些基本的用法
比如定义了一个数组 $arrColors = "blue", "red", "green", "yellow", "white", "pink", "orange", "turquoise"
看看是否包含某个元素,一般都是做个循环去查找,但是powershell不用,直接用-contains 就可
$arrColors -contains "black"
#Result PS> False
Note: 1. 字母大小写敏感用-ccontains
2. 不包含用-notcontains
========================================
添加元素还是用+
$arrColors += "black"
===========================================
查看某个以bl 开头的元素 用-like 和wildcard *
$arrColors -like "bl*"
============================================
如果想new 一个新的元素。包含了上面的bl 开头的元素。。
$arrSubset = $arrColors -like "bl*"
=============================================
可以用管道符sort-object 排序
$arrColors = $arrColors | Sort-Object
- What Is (and What Isn’t) in Our Array?
- What UML Is and Isn't
- What Refactoring is, and what it isn’t
- What is autoboxing and unboxing in Java
- What is aliasing and what causes it?
- What is YAML? & Ain't
- An engineer's view on what works and what doesn't in headhunting
- An engineer's view on what works and what doesn't in headhunting
- An engineer's view on what works and what doesn't in headhunting
- An engineer's view on what works and what doesn't in headhunting
- What is Thin Provision and Thin Reclamation in Storage Industry
- What is Managed Code and Unmanaged Code in .Net Framework
- What is the difference between BIT and TINYINT in MySQL
- What is reflection and how to use it in CSharp ?
- What is Index and how it works in SQL Server?
- What is the difference between fprintf and vfprintf in C++?
- what is the difference between definition and declaration in c
- What is SGID and how to set SGID in Linux?
- -webkit-tap-highlight-color
- 【iOS开发】---- 转场动画 CATransition
- [转]分享一个算法网址
- 深入浅出学WPF窗口- [WPF学习总结]
- Git 基本配置
- What Is (and What Isn’t) in Our Array?
- mysql 多表连接 left join 等
- 第四课 SS7产品简介
- VFP程序提示找不到别名
- HDU3662(求三维凸包表面的多边形个数,表面三角形个数,体积,表面积,凸包重心,凸包中点到面的距离)
- 如何清空NSMutableData内存
- Hibernate 本地SQL查询
- 看老外程序员如何向妻子解释设计模式
- call stack