
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 2587 Articles for Csharp

774 Views
Bitwise operator works on bits and performs bit by bit operation. In Bitwise right shift operator the value of the left operand is moved right by the number of bits specified by the right operand.In the below code, we have the value −60 i.e. 0011 1100On the right shift %minus;c = a >> 2;It converts into 15 after right shift twice −15 i.e. 0000 1111ExampleYou can try to run the following code to implement Bitwise right shift operator in C# −using System; using System.Collections.Generic; using System.Text; namespace Demo { class toBinary { static void Main(string[] args) ... Read More

293 Views
To convert binary to decimal, here I have used a while loop and found the remainder of the Binary number, which is the input. After that, the remainder is multiplied by the base value and added.This is what I did to get the decimal value −while (val > 0) { remainder = val % 10; myDecimal = myDecimal + remainder* baseVal; val = val / 10; baseVal = baseVal * 2; }ExampleLet us see the complete code to convert binary to decimal in C# −Live Demousing System; using System.Collections.Generic; using System.Text; namespace Demo { class ... Read More

12K+ Views
The binary search algorithm works on the divide and conquer principle as it keeps dividing the array in half before searching. To search for an element in an array using binary search, the array should be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left sub-array, right sub-array, or return the middle element. In this article, we are given a sorted array of integers, and our task is to search for the given target element using binary ... Read More

563 Views
Use the BigInteger to handle big numbers in C#. The assembly to add for BigInteger is System. Numerics.In c# Big integer is found in System.Numerics.BigInteger.SyntaxThe syntax of BigInteger −[SerializableAttribute] public struct BigInteger : IFormattable, IComparable, IComparable, IEquatableLet us see an example code snippet −BigInteger num = BigInteger.Multiply(Int64.MaxValue, Int64.MaxValue);You can create BigInteger like this −BigInteger num = new BigInteger(double.MaxValue);The following are some of its constructors −S.No.Constructor & Description1BigInteger(Byte[ ])A new instance of the BigInteger structure using the values in a byte array.2BigInteger(Decimal)A new instance of the BigInteger structure using a Decimal value. 3BigInteger(Double)A new instance of ... Read More

1K+ Views
To create a calculator program in C#, you need to use Web Forms. Under that create buttons from 1-9, addition, subtraction, multiplication, etc.Let us see the code for addition, subtraction, and multiplication. Firstly, we have declared two variables −static float x, y;Now, we will see how to set codes for calculation on individual button click: Our result textbox is tbResult since we have used Windows Form as well to display the calculator −protected void add_Click(object sender, EventArgs e) { x = Convert.ToInt32(tbResult.Text); tbResult.Text = ""; y = '+'; tbResult.Text += y; } protected void sub_Click(object sender, ... Read More

2K+ Views
As the name suggests the Background Worker Class allows you to set a thread continuously running in the background and communicating with the main thread whenever required.BackgroundWorker makes the implementation of threads in Windows Forms. Intensive tasks need to be done on another thread so the UI does not freeze. It is necessary to post messages and update the user interface when the task is done. The following properties are used in BackgroundWorker class:Reference: Microsoft Developer Network (MSDN)S.No.Name & Description1CancellationPendingA value indicating whether the application has requested cancellation of a background operation.2CanRaiseEventsGets a value indicating whether the component can raise an ... Read More

813 Views
A thread is defined as the execution path of a program. Each thread defines a unique flow of controlBackground ThreadsWhen the foreground threads will close, the background threads will be terminated.The property used for background thread is IsBackground that gets or sets a value indicating whether a thread is a background thread. The default value of this property would be false because the default threads created are Foreground Threads.To create a background thread −Thread bgThread = new Thread(tStart); bgThread.IsBackground = true; bgThread.Start();Foreground ThreadsForeground threads continue to run until the last foreground thread is terminated.When all the foreground threads are stopped, ... Read More

2K+ Views
BoxingBoxing is the implicit conversion of a value type to a reference type.UnboxingUnboxing is the explicit conversion of the reference type created by boxing, back to a value type.ExampleLet us see an example code snippet −// int int myVal = 12; // Boxing object myBoxed = myVal; // Unboxing int myUnBoxed = (int) myBoxed;Let us see another example that shows an array list in C# −int a = 5; ArrayList arr = new ArrayList(); // Boxing arr.Add(a); // UnBoxing int b = (int)arr[0];

1K+ Views
The async and await keyword is used in C# for asynchronous programming.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 to messages if the processing takes more time than expected.Let us see what is discussed above −private void OnRequestDownload(object sender, RoutedEventArgs e) { var req = HttpWebRequest.Create(_requestedUri); var res = req.GetResponse(); }To solve the above issue, use the async and await keywords −private async ... Read More

6K+ Views
Association in C#The association defines the relationship between an object in C#. An a one-to-one, one-to-many, many-to-one and many-to-many relationship can be defined between objects.For example, An Employee can be associated with multiple projects, whereas a project can have more than one employee.Composition in C#Under Composition, if the parent object is deleted, then the child object also loses its status.The composition is a special type of Aggregation and gives a part-of relationship.For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.Aggregation in C#Aggregation is a direct relation between objects in C#. It ... Read More