Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,928 questions

51,861 answers

573 users

How to convert a string lowercase characters to uppercase and uppercase to lowercase with C#

2 Answers

0 votes
using System;
using System.Text;

class Program
{
    static string flip_characters(string s) { 
        int len = s.Length; 
 
        StringBuilder sb = new StringBuilder(s);
        
        for (int i = 0; i < len; i++) { 
             if (sb[i] >= 'A' && sb[i] <= 'Z') 
                 sb[i] = Char.ToLower(sb[i]);
             else 
                if (sb[i] >= 'a' && sb[i] <= 'z') 
                    sb[i] = Char.ToUpper(sb[i]);
        } 
   
        return sb.ToString();
    } 
    static void Main() {
        string s = "cShaRP pRograMMinG"; 
 
        s = flip_characters(s);

        Console.Write(s);
    }
}



/*
run:

CsHArp PrOGRAmmINg

*/

 



answered Nov 16, 2019 by avibootz
0 votes
using System;
using System.Text;
 
class Program
{
    static string flip_characters(string s) { 
        int len = s.Length; 
  
        StringBuilder sb = new StringBuilder(s);
        
        for (int i = 0; i < len; i++) { 
             if ((sb[i] >= 65 && sb[i] <= 90) || (sb[i] >= 97 && sb[i] <= 122)) {
                  sb[i] = (char)(ch ^ 32);
            }
        } 
    
        return sb.ToString();
    } 
    static void Main() {
        string s = "cShaRP pRograMMinG"; 
  
        s = flip_characters(s);
 
        Console.Write(s);
    }
}
 
 
 
/*
run:
 
CsHArp PrOGRAmmINg
 
*/

 



answered Nov 19, 2019 by avibootz
...