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
Programming Articles - Page 3157 of 3363
321 Views
A delegate in C# is a reference to the method. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.Let us see how to declare delegates in C# −delegate Let us see an example to learn how to work with Delegates in C# −Example Live Demousing System; using System.IO; namespace DelegateAppl { class PrintString { static FileStream fs; static StreamWriter ... Read More
868 Views
An iterator method performs a custom iteration over a collection. It uses the yield return statement and returns each element one at a time. The iterator remembers the current location and in the next iteration the next element is returned.The following is an example −Example Live Demousing System; using System.Collections.Generic; using System.Linq; namespace Demo { class Program { public static IEnumerable display() { int[] arr = new int[] {99, 45, 76}; foreach (var val in arr) { yield return val.ToString(); ... Read More
681 Views
Stack class represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items.The following is the property of Stack class −Count − Gets the number of elements in the stack.Push OperationAdd elements in the stack using the Push operation −Stack st = new Stack(); st.Push('A'); st.Push('B'); st.Push('C'); st.Push('D');Pop OperationThe Pop operation removes elements from the stack starting from the element on the top.Here is an example showing how to work with Stack class and its Push() and Pop() method −Using System; using System.Collections; namespace CollectionsApplication { class Program ... Read More
346 Views
If you want to add a comment that restricts itself to a single line, then use the single-line comments −// variable int i = 20;The following is a sample C# program showing how to add single-line comments −Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { // display text Console.WriteLine("Hello World"); Console.ReadKey(); } } }OutputHello World
6K+ Views
StackStack class represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items.The following is the property of Stack class −Count− Gets the number of elements in the stack.The following are the methods of Stack class −Sr.No.Method & Description1public virtual void Clear();Removes all elements from the Stack.2public virtual bool Contains(object obj);Determines whether an element is in the Stack.3public virtual object Peek();Returns the object at the top of the Stack without removing it.4public virtual object Pop();Removes and returns the object at the top of the Stack.5public virtual void Push(object obj);Inserts an object ... Read More
3K+ Views
Ternary operator is a Conditional operator in C#. It takes three arguments and evaluates a Boolean expression.For example −b = (a == 1) ? 20 : 30;Above, if the first operand evaluates to true (1), the second operand is evaluated. If the first operand evaluates to false (0), the third operand is evaluated.The following is an example −Example Live Demousing System; namespace DEMO { class Program { static void Main(string[] args) { int a, b; a = 10; b = (a == 1) ? 20 : 30; Console.WriteLine("Value of b is {0}", b); b = (a == 10) ? 20 : 30; Console.WriteLine("Value of b is {0}", b); Console.ReadLine(); } } }OutputValue of b is 30 Value of b is 20
3K+ Views
We can define class members as static using the static keyword. When we declare a member of a class as static, it means no matter how many objects of the class are created, there is only one copy of the static member.The keyword static implies that only one instance of the member exists for a class. Static variables are used for defining constants because their values can be retrieved by invoking the class without creating an instance of it.The following is an example showing the usage of static variables −Example Live Demousing System; namespace StaticVarApplication { class StaticVar { ... Read More
733 Views
A thread is defined as the execution path of a program. Each thread defines a unique flow of control. If your application involves complicated and time-consuming operations, then it is often helpful to set different execution paths or threads, with each thread performing a particular job.The life cycle of a thread starts when an object of the System.Threading.Thread class is created and ends when the thread is terminated or completes execution.The following are the various states in the life cycle of a thread −The Unstarted State - It is the situation when the instance of the thread is created but ... Read More
2K+ Views
A pointer is a variable whose value is the address of another variable i.e., the direct address of the memory location. Similar to any variable or constant, you must declare a pointer before you can use it to store any variable address.The syntax of a pointer is −type *var-name;The following is how you can declare a pointer type −int *ip; /* pointer to an integer */ double *dp; /* pointer to a double */C# allows using pointer variables in a function of code block when it is marked by the unsafe modifier. The unsafe code or the unmanaged code is ... Read More
3K+ Views
Polymorphism can be static or dynamic. In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time.Compile Time Polymorphism or Static BindingThe mechanism of linking a function with an object during compile time is called early binding. It is also called static binding or early binding.Run Time Polymorphism or Dynamic BindingRuntime polymorphism has method overriding that is also known as dynamic binding or late binding.Abstract classes contain abstract methods, which are implemented by the derived class. The derived classes have more specialized functionality. Dynamic polymorphism is implemented by abstract classes and virtual functions.Read More