this is my program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
       
        static void Main(string[] args)
        {
            char[] d = new char[12];
            string dd = "5Ed5v3a4r3d4";
            for (int i = 0; i < dd.Length; i++)
            {
               
                d[i] = dd[i];
              {
               if (d[i] >= 'a' && d[i] <= 'z' || d[i] >= 'A' && d[i] <= 'Z')
               {
                        Console.WriteLine(d[i]);
               }
              }
            }
            Console.ReadLine();        
        }
    }
}

now,i want that I use the term conditional:

if (d[i] >= 0 && d[i] <= 9)

What should I do?
If I just want the resulting string in another string to copy what I should do?
Thank you.

Recommended Answers

All 5 Replies

check this code this will perfectly separate digits and characters

string dd = "5Ed5v3a4r3d4";
int k=0,j=0;
char[] char1=new char[6];
char[] numbers = new char[6];

for (int i=0;i<dd.Length;i++
{  
     if (char.IsDigit(dd, i) 
{
        numbers[j]=dd[i];
       j++;
}
else
{
char1[k]=dd[i];
k++;
}
}

Thank you very much.
its very god idea.
just 1 question about this title.
if i want get a string from the user,but i don't know user how many characters enter in textbox or string text?
what should we do in this time? Should I use the Jagged array?
Thank you for your attention.

Let the user input his string, then use the ToCharArray method of the string class.

thank you.
may be You have an example about this question for me?

Do you know what Google and MSDN are?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.