This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Write Program For Which Reads Second Character Of A String In C#?

I want to write code which reads second character of a string i have tried but expected output is not getting. This is my code

        Console.WriteLine("Enter the Sentence:");
        string str;
        str = Console.ReadLine();

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] % 2 == 1)
            {
                Console.Write(str[i]);
            }                
        }
        Console.ReadLine();


          Output:
          Enter the Sentence:
          miccroo ssooffttt
          micccossoo

This ouput i am getting

i want this output "mcro softt"

Can anyone help me?

What does this have to do with bioinformatics? You should try stackexchange. I'll close this and reopen if you add details describing how this is relevant for this site.

Also, taking the modulus of the ascii representation of a character is probably not what you want to do (unless % has a totally different meaning here).

This question will also be deleted, needs to be posted to StackOverflow

0 answers

No answers yet.

Log in to answer this question.