-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Pandurang_Nayak
Message 4 in Discussion


 
I just wrote an entire C# windows app. Took 
me about 12 minuts (I timed myself).
 
The main part of the code:


private string rotate13(string inputStr)

{

string outputStr = 
"";

foreach(char x in inputStr)

{

outputStr += Char.IsLetter(x) ? (Char.IsUpper(x) ? ((int) x < 78 ? (char) ((int) x + 
13) : (char) ((int) x - 13)) : ((int) x < 110 ? (char) ((int) x + 13) : (char) ((int) 
x - 13))) : x;

}

return outputStr;

}
That's about 5 lines of code :)
 
rgds
Pandurang

 

  
  -----Original Message-----
From: BDOTNET 
  [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 22, 2003 
  4:04 PM
To: BDOTNET
Subject: Re: rot13 - awesome 
  powa


  
    
      
      New Message on BDOTNET
    
      

  rot13 - 
    awesome powa


    
      
      
        Reply

        
          
            
            
               
              Recommend 
              Message 3 in 
                Discussion 
      
        
          
            
            
              From: Richard-Hsu 
            
              

                
                Hi,
                 
                Well, I said that it should be simple to implement a 
                working version. I was wrong, it wasn't simple, at least not 
                like a 5 mins job that I meant. But here is a working version of 
                rot13 :-
                 
                To 
                see the full code (with comments) online go to :-
http://richard_hsu.europe.webmatrixhosting.net/community/showcode.aspx?file=rot13.cs
                 
                Here 
                is the bare minimum code fragment for those of us who are 
                impatient types :-
                    static string Rot13It(string 
                text)
    
                {
        string result = 
                "";
        
                
        char 
                alpha;
        
                
        foreach(Char 
                eachAlpha in text) 
                {
        
                
            
                alpha = eachAlpha; 
                
            
                
            
                char firstAlpha, 
                lastAlpha;
                
                
            
                if (Char.IsLetter(alpha)) 
                {
                
                
                
                if (Char.IsLower(alpha)) 
                {
                    
                firstAlpha = 
                'a';
                    
                lastAlpha = 
                'z';
                
                } else 
                {                    
                
                    
                firstAlpha = 
                'A';
                    
                lastAlpha = 
                'Z';
                
                }
                                
                alpha = (char)(alpha + 13);
                                
                if (alpha > lastAlpha) 
                {
                    
                alpha = (char) (alpha - lastAlpha + firstAlpha - 1) 
                ;
                
                }
            
                }
            
                
            
                result += alpha;
        
                }
        
                
        return 
                result;
    }
                 
                Awaiting feedback and possibly 
                some code.
                 
                Regards,
Richard.
View other groups in this 
    category. 



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to