As I represent that in C#? 
Author Message
 As I represent that in C#?

What the correct sintax of the code below:

switch (StrAnalisa[Position])

{

case 0..9 : goto lb2;

case a..z : goto lb4;

Quote:
}

The problema are in 0..9 and a..z. As I represent that in C#?


Tue, 02 Mar 2004 22:36:16 GMT  
 As I represent that in C#?
Hi:
I think you will have to diaply all the characters against whom the code
needs to be checked.
 switch (StrAnalisa[Position])
 {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
            // do something will apply to all the characters which are
numbers
            break;
    case 'a' :    // display all alphabets
    case 'z'  :
          // do something
        break;
 }

hth,
Priti


Quote:
> What the correct sintax of the code below:

> switch (StrAnalisa[Position])

> {

> case 0..9 : goto lb2;

> case a..z : goto lb4;

> }

> The problema are in 0..9 and a..z. As I represent that in C#?



Tue, 02 Mar 2004 23:11:54 GMT  
 As I represent that in C#?
I think I'd do it as:

if (Char.IsNumber(StrAnalisa[Position]))
{
    ...

Quote:
}

else if (Char.IsLower(StrAnalisa[Position]))
{
    ...

Quote:
}



Quote:
> What the correct sintax of the code below:

> switch (StrAnalisa[Position])

> {

> case 0..9 : goto lb2;

> case a..z : goto lb4;

> }

> The problema are in 0..9 and a..z. As I represent that in C#?



Wed, 03 Mar 2004 02:29:35 GMT  
 As I represent that in C#?
char c = StrAnalisa[Position];
if(c >= '0' && c <= '9')
{
        // do something here
Quote:
}

else if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
{
        // do something else here

Quote:
}


Quote:
> What the correct sintax of the code below:

> switch (StrAnalisa[Position])

> {

> case 0..9 : goto lb2;

> case a..z : goto lb4;

> }

> The problema are in 0..9 and a..z. As I represent that in C#?



Wed, 03 Mar 2004 04:59:24 GMT  
 As I represent that in C#?
Yeah,
    Better choice.

    What the hell do you want to do with so many "case <x>" typo?

--
Happy Hacking!

--------------------------------------------
Gaurav Vaish,
Senior Undergraduate,
Room F-303, Hall 1,
Department of Electrical Engineering
Indian Institute of Technology,
Kanpur, INDIA - 208016
--------------------------------------------


: char c = StrAnalisa[Position];
: if(c >= '0' && c <= '9')
: {
: // do something here
: }
: else if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
: {
: // do something else here
: }
:
:


: > What the correct sintax of the code below:
: >
: > switch (StrAnalisa[Position])
: >
: > {
: >
: > case 0..9 : goto lb2;
: >
: > case a..z : goto lb4;
: >
: > }
: >
: > The problema are in 0..9 and a..z. As I represent that in C#?



Sat, 06 Mar 2004 14:56:59 GMT  
 As I represent that in C#?
Actually for this case, character handling, I would say that Eric
Gunnerson's solution is much better...
Quote:

> Yeah,
>     Better choice.

>     What the hell do you want to do with so many "case <x>" typo?

> --
> Happy Hacking!

> --------------------------------------------
> Gaurav Vaish,
> Senior Undergraduate,
> Room F-303, Hall 1,
> Department of Electrical Engineering
> Indian Institute of Technology,
> Kanpur, INDIA - 208016
> --------------------------------------------



> : char c = StrAnalisa[Position];
> : if(c >= '0' && c <= '9')
> : {
> : // do something here
> : }
> : else if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
> : {
> : // do something else here
> : }
> :
> :


> : > What the correct sintax of the code below:
> : >
> : > switch (StrAnalisa[Position])
> : >
> : > {
> : >
> : > case 0..9 : goto lb2;
> : >
> : > case a..z : goto lb4;
> : >
> : > }
> : >
> : > The problema are in 0..9 and a..z. As I represent that in C#?



Sat, 06 Mar 2004 17:26:37 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Best Way To Represent Flags That Can Be OR'd Together

2. I'm building a GUI that represents a graph data structure in particular adjaceny matricies

3. How did %d come to represent an integer?

4. Is there a component to represent mapping

5. best data structure to represent a graph ?

6. What Color represents the system text background?

7. Trouble representing signed 16 bit number as two signed 8 bit numbers

8. Data type for representing very large numbers

9. What does %*.* in printf represent?

10. int represented as string

11. keyboard representing ?

12. How to represent a two dimensional string?

 

 
Powered by phpBB® Forum Software