0

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.

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by ddanbe
0

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++;
}
}

Edited by abelLazm: n/a

0

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.

0

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

1

Do you know what Google and MSDN are?

Edited by ddanbe: grammatical typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.