- Trending Categories
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
Found 2628 Articles for Csharp
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
245 Views
Set a character with WhiteSpace −char c = ' ';To check if a character is a whitespace character, use the char.IsWhiteSpace method −if (char.IsWhiteSpace(c)) {}Let us see the complete code −Example Live Demousing System; class Demo { static void Main() { char c = ' '; if (char.IsWhiteSpace(c)) { Console.WriteLine("Whitespace character!"); } } }OutputWhitespace character!
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
66 Views
With C#, you can easily set a 6-item tuple.The following is a 6-item tuple −var myTuple = new Tuple("electronics", new string[] { "shoes", "clothing#", "accessories" }, 100, 250, 500, 1000);above, we have tuple for string, string array and int as shown below −TupleHere is the complete code −Example Live Demousing System; class Demo { static void Main() { var myTuple = new Tuple("electronics", new string[] { "shoes", "clothing#", "accessories" }, 100, 250, 500, 1000); // Displaying Item 1 Console.WriteLine(myTuple.Item1); // Displaying Item 5 Console.WriteLine(myTuple.Item5); // Displaying Item 6 Console.WriteLine(myTuple.Item6); } }Outputelectronics 500 1000
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
83 Views
To create a tuple, use the Tuple.Create method.Here we have set a tuple with a string and int −var myTuple = Tuple.Create("marks", 100);The following is an example that creates a tuple using Tuple.Create and displays the elements in a single line in C# −Example Live Demousing System; class Demo { static void Main() { var myTuple = Tuple.Create("marks", 100); Console.WriteLine(myTuple); } }Output(marks, 100)
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
403 Views
Let’s say the following is the number −int a = 12250;You can work around the following ways to get a number in hexadecimal format −{0:x} {0:x8} {0:X} {0:X8}Here is the code −Example Live Demousing System; class Demo { static void Main() { int a = 12250; Console.WriteLine("{0:x}", a); Console.WriteLine("{0:x8}", a); Console.WriteLine("{0:X}", a); Console.WriteLine("{0:X8}", a); } }Output2fda 00002fda 2FDA 00002FDA
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
450 Views
Firstly, set a string i.e. your Windows directory path −string str = @"D:\Downloads\Amit";Now use the Split() method and split wherever the \ occur −str.Split(' \')The following is the complete code −Example Live Demousing System; class Program { static void Main() { string str = @"D:\Downloads\Amit"; Console.WriteLine("Directory..."+str); string[] myStr = str.Split('\'); Console.WriteLine("Split..."); foreach (string ch in myStr) { Console.WriteLine(ch); } } }OutputDirectory... D:\Downloads\Amit Split... D: Downloads Amit
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
2K+ Views
Firstly, set a string −string str = "Science and Mathematics";Now use the Split() method to split wherever the spaces occur −str.Split(' ')The following is the complete code −Example Live Demousing System; using System.Linq; using System.IO; class Program { static void Main() { string str = "Science and Mathematics"; Console.WriteLine("String..."+str); string[] myStr = str.Split(' '); Console.WriteLine("Splitted String..."); foreach (string ch in myStr) { Console.WriteLine(ch); } } }OutputString... Science and Mathematics Splitted String... Science and Mathematics
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
644 Views
Set a string array and convert it to character array −string str = "Amit"; char[] arr = str.ToCharArray();Now, use the Reverse method to display the above string in reverse alphabetic order −Array.Reverse(arr);Here is the complete code −Example Live Demousing System; using System.Linq; using System.IO; class Program { static void Main() { string str = "Amit"; char[] arr = str.ToCharArray(); Console.WriteLine("Original String: "+str); // Reverse Array.Reverse(arr); Console.WriteLine("Reversed String: "+new string(arr)); } }OutputOriginal String: Amit Reversed String: timA
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
326 Views
FileInfo type has a Length property that determines how many bytes a file has.Firstly, set the file −FileInfo file = new FileInfo("D:ew");Now use the Length property −file.LengthHere is the complete code −Exampleusing System; using System.Linq; using System.IO; class Program { static void Main() { FileInfo file = new FileInfo("D:ew"); long res = file.Length; Console.WriteLine("Bytes: "+res); } }OutputThe following is the output −3259244
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
848 Views
To get the list of files in a directory, use the SearchOptions.AllDirectories in C#.Firstly, set the directory for which you want the files −string[] myFiles = Directory.GetFiles("D:\New\", "*.*", SearchOption.AllDirectories);The following is an example displaying files from the above mentioned directory −Exampleusing System; using System.Linq; using System.IO; class Program { static void Main() { string[] myFiles = Directory.GetFiles("D:\New\", "*.*", SearchOption.AllDirectories); foreach (string res in myFiles) { Console.WriteLine(res); } } }OutputThe following is the output. It lists all the directories of the folder −D:\New\one.txt D:\New\two.html D:\Newature.png
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
256 Views
The SequenceEqual method is used to test collections for equality.Let us set three string arrays −string[] arr1 = { "This", "is", "it" }; string[] arr2 = { "My", "work", "report" }; string[] arr3 = { "This", "is", "it" };Now, compare the first array with the second using the SequenceEqual() method −arr1.SequenceEqual(arr2);The following is an example −Example Live Demousing System; using System.Linq; class Program { static void Main() { string[] arr1 = { "This", "is", "it" }; string[] arr2 = { "My", "work", "report" }; string[] arr3 = { "This", "is", "it" }; bool res1 = arr1.SequenceEqual(arr2); Console.WriteLine(res1); bool res2 = arr1.SequenceEqual(arr3); Console.WriteLine(res2); } }OutputFalse True