C#字符串判断
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = textBox1.Text;
string newstr2 = ""; //用来保存过滤之后的串
int zimu = 0; int shuzi = 0; int qita = 0;
for (int i = 0; i < str.Length; i++)
{
if (str[i] >= '0' && str[i] <= '9')
{ //如果是数字,那么统计并放到新串中
shuzi++;
newstr2 += str[i];
}
else if (str[i] >= 'a' && str[i] <= 'z' || str[i] >= 'A' && str[i] <= 'Z')
{
zimu++;
}
else
{ //如果是其他,那么统计并放到新串中
newstr2 += str[i];
}
qita = str.Length - zimu - shuzi;
textBox2.Text = zimu.ToString();
textBox3.Text = shuzi.ToString();
textBox4.Text = qita.ToString();
}
string newstr="";
//反序
for (int i = str.Length - 1; i >= 0; i--)
{
newstr += str[i];
}
textBox6.Text = newstr;
//判断是否是回文
if (str == newstr)
{
textBox5.Text = "yes";
}
else
{
textBox5.Text = "no";
}
//输出过滤后的串
textBox7.Text = newstr2;
}
}
}
C#字符串判断的更多相关文章
- shell 字符串判断
字符串的判断 '-z 字符串' 判断字符串是否为空(为空返回真) '-n 字符串' 判断字符串是否为非空(非空返回真) '字符串1==字符串2' 判断字符串1是否和字符串2相等(相等返回真) '字符串 ...
- 由一篇吐槽对String空字符串判断的文章所引发的碎碎念
一.起因 最近有篇关于String空字符串判断的文章火了,老是看到这篇文章,既然如此我也只好认真看了下:程序员晒出一段代码引来无数网友狂喷!网友:你就活该当码农! 我也觉得这段代码写的不怎么的,首先程 ...
- JavaScript空字符串判断
JavaScript空字符串判断 本文完整示例代码GIT仓: 测试用例完整代码:isNullOrEmpty jPublic GIT仓:jPublic 比较常见写法 if (str == 'undefi ...
- sh_16_字符串判断方法
sh_16_字符串判断方法 # 1. 判断空白字符 space_str = " \t\n\r" print(space_str.isspace()) # 2. 判断字符串中是否只包 ...
- Shell系列(28)- 条件判断之字符串判断
字符串判断 $变量时要用双引号引起来,即"$变量" 测试选项 作用 -z 字符串 判断字符串是否为空(为空返回真) -n 字符串 判断字符串是否为非空(非空返回真) 字符串1 == ...
- 字符串判断设置TextView高度
问题:项目中需要根据字符串的长度判断Textview的高度 一.如果全是英文的也比较容易,根据长度判断从而设置mTextView的高度就好. double temp = str.length(); ...
- LINQ查询字符串判断是否大写
#region Linq to 字符串char.IsUpper意思是判断是否大写 //string strDemo = "HelloWord!"; ...
- C,C++回文字符串判断(字符串指针的用法)
功能:输入一个字符串,判断是否为回文. 主要锻炼指针的用法. 1.C版 #include<stdio.h> int main() { ]; char a; ,flag=; while((a ...
- Js字符串判断
判断字符串 str=''; if(!str) // str为null 或者"" 或者0
- Python一些字符串判断和转换
设s是字符串: s.isalnum() 判断所有字符都是数字或者字母 s.isalpha() 判断所有字符都是字母 s.isdigit() 判断所有字符都是数字 s.islower() ...
随机推荐
- AndroidSlideTest.java
以下代码使用ApiDemos-debug.apk进行测试 package com.saucelabs.appium; import io.appium.java_client.AppiumDriver ...
- jQuery事件函数位置放置的两种方法
jQuery 事件函数 jQuery 事件处理方法是 jQuery 中的核心函数. 事件处理程序指的是当 HTML 中发生某些事件时所调用的方法. 通常会把 jQuery 代码放到 <head& ...
- Spring 4.2框架中注释驱动的事件监听器详解
事件交互已经成为很多应用程序不可或缺的一部分,spring框架提供了一个完整的基础设施来处理瞬时事件.下面我们来看看Spring 4.2框架中基于注释驱动的事件监听器. 1.早期的方式 在早期,组件要 ...
- Chapter 3 Shared Assemblies and Strongly Named Assemblies
As time marches on,MS developers and control developer modify their code:they fix bugs,patch securit ...
- phpcms v9中的$CATEGORYS栏目数组
首先 如果不能用$CATEGORYS这个数组或掉不出来内容应加入 $CATEGORYS = getcache('category_content_1','commons'); 1.用途 $CATEGO ...
- OJ提交题目中的语言选项里G++与C++的区别
一.OJ提交题目中的语言选项里G++与C++的区别 http://www.th7.cn/Program/cp/201405/199001.shtml 首先更正一个概念,C++是一门计算机编程语言,G+ ...
- FFT的常数优化
卡得一手好常数..学习了..(似乎只对FFT有效) JZOJ 4349 #include <bits/stdc++.h> #define LL long long #define DB l ...
- python3 分布式进程(跨机器)BaseManager(multiprocessing.managers)
A机器负责发送任务和接受结果: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #ta ...
- 如何找GitHub上热门的开源项目
访问:https://github.com/trending,选择时间段和关联语言就可以查看最近热门的项目. Java最近一个月热门项目如下:
- bzoj2875随机数生成器——矩阵快速幂
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2875 矩阵快速幂,把x和c分开求,最后加上即可: 为防止爆long long,要用快速乘. ...