- 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
We have a sample string with spaces −str ="Hello World !";Use the Replace() method in C# to replace all spaces in a string with ‘%20’ −str2 = str.Replace(" ", "%20");ExampleYou can try to run the following code to replace all spaces in a string with ‘%20’.Live Demousing System; class Demo { static void Main() { String str, str2; str ="Hello World !"; Console.WriteLine("String: "+str); str2 = str.Replace(" ", "%20"); Console.WriteLine("String (After replacing): "+str2); } }OutputString: Hello World ! String (After replacing): Hello%20World%20!
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
190 Views
Firstly, initialize three sorted arrays −int []one = {20, 35, 57, 70}; int []two = {9, 35, 57, 70, 92}; int []three = {25, 35, 55, 57, 67, 70};To find common elements in the three-sorted arrays, iterate through the arrays using a while loop and check the first array with a second and second array with the third −while (i < one.Length && j < two.Length && k < three.Length) { if (one[i] == two[j] && two[j] == three[k]) { Console.Write(one[i] + " "); i++;j++;k++; } else if (one[i] < two[j]) ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
To find the hostname, use the Dns.GetHostName() method in C# −String hostName = string.Empty; hostName = Dns.GetHostName(); Console.WriteLine("Hostname: "+hostName);Now, use the IPHostEntry.AddressList Property to get IP Address −IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList;ExampleTry the following code to display hostname and IP address −using System; using System.Net; class Program { static void Main() { String hostName = string.Empty; hostName = Dns.GetHostName(); Console.WriteLine("Hostname: "+hostName); IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList; for (int i = 0; i < address.Length; i++) { Console.WriteLine("IP Address {1} : ",address[i].ToString()); } Console.ReadLine(); } }
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
421 Views
Firstly, create a new linked list −LinkedList myList = new LinkedList();Now add some elements in the linked list −// Add 6 elements in the linked list myList.AddLast("P"); myList.AddLast("Q"); myList.AddLast("R"); myList.AddLast("S"); myList.AddLast("T"); myList.AddLast("U");Let’s now find a node and add a new node after that −LinkedListNode node = myList.Find("R"); myList.AddAfter(node, "ADDED");ExampleYou can try to run the following code to find a node in the linked list.Live Demousing System; using System.Collections.Generic; class Program { static void Main() { LinkedList myList = new LinkedList(); // Add 6 elements in the linked list myList.AddLast("P"); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
263 Views
To show the priority of the thread in C#, use the Priority property.Firstly, use the currentThread property to display information about a thread −Thread thread = Thread.CurrentThread;Now use the thread.Priority property to display the priority of the thread −thread.PriorityExampleLet us see the complete code to show the thread’s priority in C#.Live Demousing System; using System.Threading; namespace Demo { class MyClass { static void Main(string[] args) { Thread thread = Thread.CurrentThread; thread.Name = "My Thread"; Console.WriteLine("Thread Priority = {0}", thread.Priority); Console.ReadKey(); } } }OutputThread Priority = Normal
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
165 Views
To display the name of the current thread in C#, use the Name property.Firstly, use the currentThread property to display information about a thread −Thread thread = Thread.CurrentThread;Now use the thread.Name property to display name of the thread −thread.NameExampleLet us see the complete code show current thread’s name in C#.Live Demousing System; using System.Threading; namespace Demo { class MyClass { static void Main(string[] args) { Thread thread = Thread.CurrentThread; thread.Name = "My Thread"; Console.WriteLine("Thread Name = {0}", thread.Name); Console.ReadKey(); } } }OutputThread Name = My Thread
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
7K+ Views
You need to check for both the vowels and consonants, but do not forget to check for both the uppercase as well lowercase.For counting vowels, check for “aeiou” characters separately i.e.if (myStr[i] == 'a' || myStr[i] == 'e' || myStr[i] == 'i' || myStr[i] == 'o' || myStr[i] == 'u' || myStr[i] == 'A' || myStr[i] == 'E' || myStr[i] == 'I' || myStr[i] == 'O' || myStr[i] == 'U') { vowel_count++; }ExampleThe following is the code to count the number of Vowels in a string.Live Demousing System; public class Demo { public static void Main() { ... Read More