我的問題是,我想檢查一個字符串包含一個或多個三個字符數組我成立,並在大多數情況下,我得到它的工作,但由於某種奇怪的原因一行沒有按」我想工作,我不知道我做錯了什麼。字符串包含任何字符數組
三個陣列是
一個= AF小寫字母
B = AF大寫字母
C = 1-6的數字
程序工作爲: 小寫,大寫,數字,小寫字母+數字,資本+數字和小寫+資本+數字, 但什麼是不工作是小寫+資本是(c.Any(x.Contains) == false && a.Any(x.Contains) == true && b.Any(x.Contains) == true)
代碼:
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
Char[] a = { 'a', 'b', 'c', 'd', 'e', 'f' };
Char[] b = { 'A', 'B', 'C', 'D', 'E', 'F' };
Char[] c = { '1', '2', '3', '4', '5', '6' };
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
if(textBox2.Text != "")
{
Char[] x = textBox2.Text.ToCharArray();
if (c.Any(x.Contains) == true && a.Any(x.Contains) ==false && b.Any(x.Contains)==false)
{
textBox1.Text = "num";
}
else if (b.Any(x.Contains) == true && c.Any(x.Contains) == false && a.Any(x.Contains) ==false)
{
textBox1.Text = "cap";
}
else if (a.Any(x.Contains) == true && c.Any(x.Contains) == false && c.Any(x.Contains) == false)
{
textBox1.Text = "low";
}
else if (c.Any(x.Contains) == false && a.Any(x.Contains) == true && b.Any(x.Contains) == true)
{
textBox1.Text = "low&cap";
}
else if (a.Any(x.Contains) == true && c.Any(x.Contains) == true && b.Any(x.Contains) == false)
{
textBox1.Text = "low&num";
}
else if (b.Any(x.Contains) == true && c.Any(x.Contains) == true && a.Any(x.Contains) == false)
{
textBox1.Text = "cap&num";
}
else if (a.Any(x.Contains) == true && b.Any(x.Contains) == true && c.Any(x.Contains) == true)
{
textBox1.Text = "cap&num&low";
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
正向
編輯
沒關係謝謝,我只是理解了它 的程序中的小寫唯一的選擇第一,並沒有再費心找。 ..
FYI:你在你的代碼有邏輯問題。 – jp2code 2013-04-10 21:09:28
好的,謝謝,我注意到它只是後,我問的問題 – WolfyD 2013-04-11 21:37:38