![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# ToUpper() Method
The ToUpper() method in C# is used to return a copy of this string converted to uppercase.
Syntax
public string ToUpper ();
Example
using System; public class Demo { public static void Main(String[] args) { string str1 = "Welcome!"; string str2 = "Thisisit!"; char[] arr1 = str1.ToCharArray(3,2); char[] arr2 = str2.ToCharArray(2,2); Console.WriteLine("String1 = "+str1); Console.WriteLine("String1 ToUpper = "+str1.ToUpper()); Console.WriteLine("String1 Substring from index4 = " + str1.Substring(4, 4)); Console.Write("Character array...String1 ="); for (int i = 0; i < arr1.Length; i++) Console.Write(" " + arr1[i]); Console.WriteLine("
String2 = "+str2); Console.WriteLine("String2 ToUpper = "+str2.ToUpper()); Console.WriteLine("String2 Substring from index2 = " + str2.Substring(0, 5)); Console.Write("Character array...String2 ="); for (int i = 0; i < arr2.Length; i++) Console.Write(" " + arr2[i]); } }
Output
String1 = Welcome! String1 ToUpper = WELCOME! String1 Substring from index4 = ome! Character array...String1 = c o String2 = Thisisit! String2 ToUpper = THISISIT! String2 Substring from index2 = Thisi Character array...String2 = i s
Example
using System; using System.Globalization; public class Demo { public static void Main(String[] args) { string str1 = "JackSparrow!"; string str2 = "@#$PQRSTUV!"; Console.WriteLine("String1 = "+str1); Console.WriteLine("String1 ToUpper = "+str1.ToUpper(new CultureInfo("en-US", false))); Console.WriteLine("String1 Substring from index4 = " + str1.Substring(2, 2)); Console.WriteLine("
String2 = "+str2); Console.WriteLine("String2 ToUpper = "+str2.ToUpper(new CultureInfo("en-US", false))); Console.WriteLine("String2 Substring from index2 = " + str2.Substring(0, 5)); } }
Output
String1 = JackSparrow! String1 ToUpper = JACKSPARROW! String1 Substring from index4 = ck String2 = @#$PQRSTUV! String2 ToUpper = @#$PQRSTUV! String2 Substring from index2 = @#$PQ
Advertisements