- 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 34488 Articles for Programming
![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)
427 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
210 Views
The number for our example is 11 i.e. binary −1101The total set bits are 3 in 1101; to find it, use a loop till it’s not equal to 0. Here, our num is 11 i.e. decimal −while (num>0) { cal += num & 1; num >>= 1; }ExampleTo count total set bits in a number, use the following code.Live Demousing System; public class Demo { public static void Main() { int cal = 0; // Binary is 1011 int num = 11; while (num>0) { cal += num & 1; num >>= 1; } // 1 bits in 1101 are 3 Console.WriteLine("Total bits: "+cal); } }OutputTotal bits: 3
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
403 Views
Let us say the number we have is 12. We have declared and initialized a uint variable by assigning a decimal literal,uint val = 12;The binary representation of 12 is −1100The bits above is 4, therefore to find the total bits, use the Math.log() method −uint res = (uint)Math.Log(val , 2.0) + 1;ExampleYou can try to run the following code to count total bits in a number.Live Demousing System; public class Demo { public static void Main() { uint val = 12; // 1100 in binary uint res = (uint) Math.Log(val, 2.0) + 1; // 1100 has 4 bits Console.WriteLine("Total bits: " + res); } }OutputTotal bits: 4