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
 
Server Side Programming Articles - Page 2501 of 2650
 
			
			468 Views
Format DateTime using String.Format method.Let us see an example −Exampleusing System; static class Demo { static void Main() { DateTime d = new DateTime(2018, 2, 8, 12, 7, 7, 123); Console.WriteLine(String.Format("{0:y yy yyy yyyy}", d)); Console.WriteLine(String.Format("{0:M MM MMM MMMM}", d)); Console.WriteLine(String.Format("{0:d dd ddd dddd}", d)); } }Above we have first set the DateTime class object −DateTime d = new DateTime(2018, 2, 8, 12, 7, 7, 123);To format, we have used the String.Format() method and displayed date in different formats.String.Format("{0:y yy yyy yyyy}", d) String.Format("{0:M MM MMM MMMM}", d) String.Format("{0:d dd ddd dddd}", d
 
			
			1K+ Views
Serialization converts objects into a byte stream and brings it to a form that it can be written on stream. This is done to save it to memory, file or database.Serialization can be performed as −Binary SerializationAll the members, even members that are read-only, are serializedXML SerializationIt serializes the public fields and properties of an object into XML stream conforming to a specific XML Schema definition language document.Let us see an example. Firstly set the stream −FileStream fstream = new FileStream("d:ew.txt", FileMode.OpenOrCreate); BinaryFormatter formatter=new BinaryFormatter();Now create an object of the class and call the constructor which has three parameters −Employee ... Read More
 
			
			595 Views
To reverse a string, use the Array. Reverse() method.We have set a method and passed the string value as “Henry” −public static string ReverseFunc(string str) { char[] ch = str.ToCharArray(); Array.Reverse(ch); return new string(ch); }In the above method, we have converted the string into character array −char[] ch = str.ToCharArray();Then the Reverse() method is used −Array.Reverse(ch);
 
			
			2K+ Views
A file is a collection of data stored in a disk with a specific name and a directory path. When a file is opened for reading or writing, it becomes a stream.The type of streams includes −Byte Streams − It includes Stream, FileStream, MemoryStream and BufferedStream.Character Streams − It includes Textreader-TextWriter, StreamReader, StraemWriter and other streams.Byte streams have classes that consider data in the stream as byte.Stream class is the base for other byte stream classes. The following are the properties −CanRead − Whether stream supports readingCanWrite − Whether stream supports writingLength − Length of the streamThe System.IO namespace has ... Read More
 
			
			706 Views
DictionaryDictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.To declare a Dictionary −IDictionary d = new Dictionary();To add elements −IDictionary d = new Dictionary(); d.Add(1,97); d.Add(2,89); d.Add(3,77); d.Add(4,88);ArrayArray stores a fixed-size sequential collection of elements of the same type. It consists of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.To define Arrays −int[] arr = new int[5]; To initialize and set elements to Arrays.int[] arr = new int[10] {3, 5, 35, 87, 56, 99, 44, 36, 78};
 
			
			4K+ Views
finalJava has final keyword, but C# does not have its implementation. For the same implementation, use the sealed keyword.With sealed, you can prevent overriding of a method. When you use sealed modifiers in C# on a method, then the method loses its capabilities of overriding. The sealed method should be part of a derived class and the method must be an overridden method.FinallyThe finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not.FinalizeThe ... Read More
 
			
			677 Views
ClassClass is a blueprint for a data type. A class definition starts with the keyword class followed by the class name.StructA structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure.The following are the differences −Classes are reference types and structs are value typesStructures do not support inheritanceStructures cannot have default constructorWhen you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the ... Read More
 
			
			1K+ Views
To implement Remove() and RemoveAt() methods in C#, try the following code −Firstly, set a list.List myList = new List() { "mammals", "reptiles", "amphibians", "vertebrate" };Now, use Remove() method to remove an element.myList.Remove("reptiles");Now, use RemoveAt() method to remove an element by setting the position.myList.RemoveAt(2);The following is the complete code −Exampleusing System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { List myList = new List() { "mammals", "reptiles", "amphibians", "vertebrate" ... Read More
 
			
			151 Views
Declaring an array does not initialize the array in the memory. When the array variable is initialized, you can assign values to the array.Array is a reference type, so you need to use the new keyword to create an instance of the array. For example, assign the values like the following statement −double[] price = new double[5]; price[0] = 3245.50; price[1] = 1234.50; price[2] = 8765.50; price[3] = 5784.50; price[4] = 6576.50;We assigned five values above to the price array. You can assign values to the array at the time of declaration.double[] price = new double[5] {3245.50, 1234.50, 8765.50, 6576.50;};
