- 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 34494 Articles for Programming
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
9K+ Views
To start a task in C#, follow any of the below given ways. Use a delegate to start a task. Task t = new Task(delegate { PrintMessage(); }); t.Start(); Use Task Factory to start a task. Task.Factory.StartNew(() => {Console.WriteLine("Welcome!"); }); You can also use Lambda. Task t = new Task( () => PrintMessage() ); t.Start();
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
72 Views
Get the keys in the SortedList using the keys property of SortedList class in C#. We have first set the SortedList property with elements.SortedList sl = new SortedList(); sl.Add("ST0", "One"); sl.Add("ST1", "Two"); sl.Add("ST2", "Three"); sl.Add("ST3", "Four"); sl.Add("ST4", "Five"); sl.Add("ST5", "Six"); sl.Add("ST6", "Seven");Now use the keys property to get the keys.ICollection key = sl.Keys;The following is the complete code to implement keys property of SortedList class.Example Live Demousing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { SortedList sl = new SortedList(); sl.Add("ST0", "One"); ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
867 Views
In Dynamic binding, the compiler will not do type checking at compile time. At run time, the checking is done.Use it to avoid the restriction of anonymous types to one method. This is only because the type name is visible only to the compiler; therefore, you cannot declare it as the return value of a method.Examplepublic dynamic GetAnonymousType() { return new { StudentName = "Tom", Subject = "Java", }; }Above, the method is set to be dynamic, that would means the compiler won’t do type checking at compile time.public dynamic GetAnonymousType() { }
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
178 Views
Asynchronous programming in C# is an efficient approach towards activities blocked or access is delayed. If an activity is blocked like this in a synchronous process, then the complete application waits and it takes more time. The application stops responding. Using asynchronous approach, the applications continues with other tasks as well.An application with a GUI, check the content of the queue and if an unprocessed task is there, it takes it out and processes it first. The code executes synchronously and the unprocessed task is completed first. The application will show stop responding messages if the processing takes more time ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
630 Views
C# exceptions are represented by classes. The exception classes in C# are mainly directly or indirectly derived from the System.Exception class. Some of the exception classes derived from the System.Exception class are the System.ApplicationException and System.SystemException classes.System.DivideByZeroException is a class that handles errors generated from dividing a dividend with zero.Example Live Demousing System; namespace ErrorHandlingApplication { class DivNumbers { int result; DivNumbers() { result = 0; } public void division(int num1, int num2) { try { ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
901 Views
ConstConstant fields are the fields that cannot be modified. At the time of declaration, you need to assign a value to it.const int a = 5;StaticIf the static modifier is applied to a class then you cannot instantiate the class using the new keyword. You can use the static keyword on methods, properties, classes, constructors, etc.static int a = 10;ReadonlyA Readonly field is initialized at the time of declaration or you can also set it within the constructor.Let us see an example in which the readonly field is initialized inside the constructor.Exampleclass Demo { readonly int a; public ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Use the System.IO.Compression Namespace in C# to compress and decompress files in C#.CompressTo zip a file, use the GZipStream class with the FileStream class. Set the following parameters: File to be zipped and the name of the output zip file.Here, outputFile is the output file and the file is read into the FileStream.Exampleusing(var compress = new GZipStream(outputFile, CompressionMode.Compress, false)) { byte[] b = new byte[inFile.Length]; int read = inFile.Read(b, 0, b.Length); while (read > 0) { compress.Write(b, 0, read); read = inFile.Read(b, 0, b.Length); } }DecompressTo decompress a file, use ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
100 Views
We have taken the number as the following −uint a = 9; uint b = 8;Above, a is a divisor and b is dividend.To compute modulus division.Example Live Demousing System; class Demo { static uint display( uint a, uint b) { return ( a & (b-1) ); } static public void Main () { uint a = 9; uint b = 6; Console.WriteLine( a + " modulus " + b + " = " + display(a, b)); } }Output9 modulus 6 = 1
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
396 Views
To define the scope and visibility of a class member, use an access specifier. C# supports the following access specifiers. Public Private Protected Internal Protected internal Let us learn about them one by one. Public Access Specifier It allows a class to expose its member variables and member functions to other functions and objects. Private Access Specifier Private access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members. Protected Access Specifier Protected access specifier allows a child class to ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
167 Views
The "is" operator in C# checks whether the run-time type of an object is compatible with a given type or not.The following is the syntax.expr is typeHere, expr is the expressiontype is the name of the typeThe following is an example showing the usage of is operator in C#.Exampleusing System; class One { } class Two { } public class Demo { public static void Test(object obj) { One x; Two y; if (obj is One) { Console.WriteLine("Class One"); x = (One)obj; ... Read More