My problem is that i want to check if a string contains one or more of three character arrays i set up, and for the most part i got it to work but for some weird reason one line doesn't want to work and i don't know what I'm doing wrong.
The three arrays are
a = a-f lowercase letters
b = A-F capital letters
c = 1-6 numbers
the program works for:
lowercase, capital, numeric, lowercase + numeric, capital + numeric and lowercase + capital + numeric,
but what isn't working is lowercase+capital which is (c.Any(x.Contains) == false && a.Any(x.Contains) == true && b.Any(x.Contains) == true)
Code:
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)
{
}
}
}
Thanks in forward
EDIT
Never mind, i just figured it out The program found the lowercase only option first and didn't bother to look further...