 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Server Side Programming Articles - Page 2522 of 2650
 
 
			
			273 Views
The increment operator is ++ operator. If used as prefix on a variable, the value of variable gets incremented by 1. After that the value is returned unlike Postfix operator. It is called Prefix increment operator. In the same way the decrement operator works but it decrements by 1.For example, ++a;The following is an example demonstrating Prefix increment 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); } }Output11 11 11
 
 
			
			332 Views
It handles errors generated from referencing a null object. The Null reference exception occurs when you are looking to access member fields or function types that points to null.Let’s say we have the following null string −string str = null;Now you try to get the length of the null string, then it would cause an exception −If(str.Length == null) {}Above the exception will be thrown. Now let us seen how to prevent the null pointer exception to be thrown −Example Live Demousing System; class Program { static void Main() { int[] arr = new int[5] {1, ... Read More
 
 
			
			287 Views
The #undef directive allows you to undefine a symbol. The following is the syntax −#undef SYMBOLFor example,#undef OneIt evaluates to false when used along with #if directive. Let us see an example −Example Live Demo#define One #undef Two using System; namespace Demo { class Program { static void Main(string[] args) { #if (One && TWO) Console.WriteLine("Both are defined"); #elif (ONE && !TWO) Console.WriteLine("ONE is defined and TWO is undefined"); #elif (!ONE && TWO) Console.WriteLine("ONE is defined and TWO is undefined"); #else Console.WriteLine("Both are undefined"); #endif } } }OutputBoth are undefined
 
 
			
			438 Views
To find the number of dimensions of an array, use the Array Rank property. This is how you can define it −arr.RankHere, arr is our array −int[,] arr = new int[3,4];If you want to get the rows and columns it has, then uses the GetLength property −arr.GetLength(0); arr.GetLength(1);The following is the complete code −Example Live Demousing System; class Program { static void Main() { int[,] arr = new int[3,4]; Console.WriteLine(arr.GetLength(0)); Console.WriteLine(arr.GetLength(1)); // Length Console.WriteLine(arr.Length); Console.WriteLine("Dimensions of Array : " + arr.Rank); } }Output3 4 12 Dimensions of Array : 2
 
 
			
			497 Views
To declare a tuple the following is the format wherein we have a tuple with int and string items −Tuple tuple = new Tuple(20, "Tom");Now, check for first item in the tuple, which is an integer −if (tuple.Item1 == 99) { Console.WriteLine(tuple.Item1); }Now check for second item in the tuple, which is a string − if (tuple.Item2 == "Tim") { Console.WriteLine(tuple.Item2); }The following is an example to create a tuple with string and int items −using System; using System.Threading; namespace Demo { class Program { static void Main(string[] args) { ... Read More
 
 
			
			300 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
 
 
			
			850 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
 
 
			
			642 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
 
 
			
			332 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