- 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)
11K+ Views
IEnumerable is an interface defining a single method GetEnumerator() that returns an IEnumerator interface. It is the base interface for all non-generic collections that can be enumerated.This works for read-only access to a collection that implements that IEnumerable can be used with a foreach statement.It has a single method −GetEnumerator() − This method returns an enumerator that iterates through a collection.The following is the implementation of the GetEnumerator() method of the IEnumerable interface in C# −IEnumerator IEnumerable.GetEnumerator() { return (IEnumerator) GetEnumerator(); }The following are the extension methods of the IEnumerable interface in C# −Sr.NoMethod Name & Description1AsParallel()Enables parallelization of a ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
The ICollection interface in C# defines the size, enumerators, and synchronization methods for all nongeneric collections. It is the base interface for classes in the System.Collections namespace.The following are the properties of ICollection interface −Sr.No.Property Name & Description1CountThe number of elements in the ICollection2SyncRootGets an object that useful to synchronize access to the ICollection.The following are the methods of ICollection interface −Sr.No.Method Name & Description1CopyTo(Array^,Int32)The method copies the elements of the ICollection to an Array.2GetEnumerator()The GetEnumerator() method returns an enumerator that iterates through a collection
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
597 Views
The increment operator is ++ operator. If used as postfix on a variable, the value of the variable is first returned and then gets incremented by 1. It is called Postfix increment operator. In the same way, the decrement operator works but it decrements by 1.For example,a++;The following is an example showing how to work with postfix operator −Example Live Demousing System; class Program { static void Main() { int a, b; a = 10; Console.WriteLine(a++); b = a; Console.WriteLine(a); Console.WriteLine(b); } }Output10 11 11
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
952 Views
All preprocessor directives begin with #, and only white-space characters may appear before a preprocessor directive on a line. Preprocessor directives are not statements, so they do not end with a semicolon (;).#ifThe #if directive allows testing a symbol or symbols to see if they evaluate to true.#elseIt allows to create a compound conditional directive, along with #if.#elifIt allows creating a compound conditional directive.#endifThe #endif specifies the end of a conditional directive.The following is an example showing the usage of #if, #elif, #else and #endif directives −Example Live Demo#define One #undef Two using System; namespace Demo { class ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
2K+ Views
Use the Name property to display the name of the current thread in C#.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.NameLet us see the complete code show current thread’s name in C# −Example 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)
427 Views
#error directiveThe #error directive allows generating an error from a specific location in your code.Let us see an example −Example Live Demousing System; namespace Demo { class Program { public static void Main(string[] args) { #if (!ONE) #error ONE is undefined #endif Console.WriteLine("Generating a user-defined error!"); } } }After running the above program, a user-defined error generates −OutputCompilation failed: 1 error(s), 0 warnings error CS1029: #error: 'ONE is undefined'#warning directiveThe #warning directive allows generating a level ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
557 Views
Use the IPHostEntry.AddressList Property to get IP Address −IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList;Try the following code to display IP address −Exampleusing 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(); } }
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
536 Views
The Abort() method is used for destroying threads.The runtime aborts the thread by throwing a ThreadAbortException. This exception cannot be caught, the control is sent to the finally block, if any.The following is an example showing how to destroy threads −Example Live Demousing System; using System.Threading; namespace MultithreadingApplication { class ThreadCreationProgram { public static void CallToChildThread() { try { Console.WriteLine("Child thread starts"); // do some work, like counting to 10 for (int counter = 0; counter
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
307 Views
The "var" keyword initializes variables with var support. Just assign whatever value you want for the variable, integer, string, float, etc.Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { var myInt = 5; var myString = "Amit"; Console.WriteLine("Rank: {0} Name: {1}",myInt,myString); } } }OutputRank: 5 Name: AmitWe can also use var in arrays −Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { var myInt = new int[] {65,43,88,56}; foreach(var val in myInt) Console.WriteLine(val); } } }Output65 43 88 56
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
632 Views
A 2-dimensional array is a list of one-dimensional arrays. Declare it like the two dimensional array shown below −int [, ] aTwo-dimensional arrays may be initialized by specifying bracketed values for each row.int [, ] a = new int [4, 4] { {0, 1, 2, 3} , {4, 5, 6, 7} , {8, 9, 10, 11} , {12, 13, 14, 15} };The following is an example showing how to work with two-dimensional arrays in C# −Example Live Demousing System; namespace ArrayApplication { class MyArray { static void Main(string[] args) { /* an ... Read More