各种语言常用的一句话判断代码
时间:2022-10-10 17:38:07
判断汉字
if (System.Text.Encoding.GetEncoding("gb2312").GetBytes("中").Length == 2) // C#
if (escape(str).indexOf("%u") < 0) // JavaScript
判断数字
Number.as(v) // ezj
Number.asInt(v) // ezj 判断整数
判断纯数字
Number.asPureNumber(v) // ezj 判断纯数字(不能有正负号、小数点)
System.Text.RegularExpressions.Regex.IsMatch(str, @"^\d+$") // C#
判断闰年
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) // C#、JavaScript
if ((year mod 4 = 0) and (year mod 100 <> 0)) or (n mod 400 = 0) then // ASP
判断页数
int totalPages = ((totalRecords - 1) / pageSize) + 1; // C#
pageCnt = Fix((recordCnt + pageSize - 1) / pageSize) // ASP
[code]
其他
[code]
string str = String.Join(",", intList.ConvertAll<string>(new Converter<int, string>(m => m.ToString())).ToArray());
// C# String.Join 对 int,核心是 int List 转 string List
// 看更简单的(.NET 4 适用):
string str = String.Join<int>(",", intList);
标签:一句话判断
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python实现淘宝秒杀聚划算抢购自动提醒源码
2022-12-04 11:43:15
Python爬虫之超级鹰验证码应用
2021-04-08 08:22:20
![](https://img.aspxhome.com/file/2023/3/107603_0s.png)
Python计算机视觉SIFT尺度不变的图像特征变换
2022-08-01 00:28:44
![](https://img.aspxhome.com/file/2023/6/72946_0s.png)
简单了解django文件下载方式
2022-10-31 08:48:32
用Python制作mini翻译器的实现示例
2021-07-26 02:48:09
![](https://img.aspxhome.com/file/2023/2/71532_0s.gif)
ipad上运行python的方法步骤
2021-12-06 19:05:36
解决mysql不能插入中文Incorrect string value
2009-07-30 09:02:00
golang语言中for循环语句用法实例
2024-04-23 09:41:21
用Python输出一个杨辉三角的例子
2023-06-04 07:32:33
MySQL 之压力测试工具的使用方法
2024-01-28 06:27:32
![](https://img.aspxhome.com/file/2023/5/116785_0s.png)
网站设计做好超级链接的重要性
2007-09-14 11:19:00
Python中的list.sort()方法和函数sorted(list)
2021-07-29 17:02:23
js Array的用法总结
2024-04-25 13:08:26
Python实现批量绘制遥感影像数据的直方图
2023-09-04 10:35:53
python递归计算N!的方法
2021-11-11 21:11:31
使用Python pandas读取CSV文件应该注意什么?
2022-06-26 16:05:50
![](https://img.aspxhome.com/file/2023/3/94093_0s.png)
Python实现微博动态图片爬取详解
2023-09-14 05:47:25
![](https://img.aspxhome.com/file/2023/0/61730_0s.jpg)
基于python生成器封装的协程类
2022-09-25 04:57:53
解决SQL SERVER数据库备份时出现“操作系统错误5(拒绝访问)。BACKUP DATABASE 正在异常终止。”错误的解决办法
2024-01-22 08:24:14
![](https://img.aspxhome.com/file/2023/5/89655_0s.jpg)
网站设计中的面包屑[译]
2009-03-22 15:42:00
![](https://img.aspxhome.com/file/UploadPic/20093/22/01-47s.jpg)