using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
    class Program
    {
     
        static void Main(string[] args)
        {
            char s;
            do
            {
                s = (char)Console.Read();
                s += (char)5;
                Console.Write(s);
            } while ('\n'==s);
                    }
    }
}实现简单的输入一行字符串进行"加密"只往后推5个.但是为什么只有第一个被加呢
我全部是输入字母

解决方案 »

  1.   

    char   s; ------》string s=“”;
      

  2.   

    或者改成这样好了string inputString = Console.ReadLine();
    foreach (char c in inputString.ToCharArray())
    {
       char tempChar = c;
       tempChar += (char)5;
       Console.Write(tempChar);
    }
      

  3.   


    using   System; 
    using   System.Collections.Generic; 
    using   System.Text; 
    using   System.IO; 
    using   System.Text.RegularExpressions; 
    namespace   ConsoleApplication1 

            class   Program 
            { 
              
                    static   void   Main(string[]   args) 
                    { 
                            string   s = Console.ReadLine();
                            for (int i=0; i<s.Length; i++)
                            {
                                 s[i] += 5;
                            }
                    } 
            }