Nizamuddin Siddiqui has Published 2303 Articles

How to convert byte array to an object stream in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 09:01:09

2K+ Views

Stream is the abstract base class of all streams and it Provides a generic view of a sequence of bytes. The Streams Object involve three fundamental operations such as Reading, Writing and Seeking. A stream be can be reset which leads to performance improvements.A byte array can be converted to ... Read More

What is the difference between Func delegate and Action delegate in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:59:02

2K+ Views

A delegate is a type that represents references to methods with a particular parameter list and return type. When we instantiate a delegate, we can associate its instance with any method with a compatible signature and return type. We can invoke (or call) the method through the delegate instance.Func DelegateFunc ... Read More

How to validate whether a string is a number in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:56:21

1K+ Views

A string having number can be validated using int.TryParse or int.Parse.Int.Parse throws an exception if it cannot parse the string to an integer, whereas Int.TryParse returns a bool indicating whether it succeeded. Also, Int.TryParse has an out parameter which has the value of the parsed string.Example Live Demousing System; namespace DemoApplication ... Read More

How to create a folder if it does not exist in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:52:58

13K+ Views

For creating a directory, we must first import the System.IO namespace in C#. The namespace is a library that allows you to access static methods for creating, copying, moving, and deleting directories.It is always recommended to check if the Directory exist before doing any file operation in C# because the ... Read More

How to convert C# DateTime to “YYYYMMDDHHMMSS” format?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:49:41

5K+ Views

Convert the dateTime to toString that results in converting the DateTime to “YYYYMMDDHHMMSS” formatThere are also other formats that the dateTime can be convertedMM/dd/yyyy 08/22/2020dddd, dd MMMM yyyy Tuesday, 22 August 2020dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2020 06:30dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2020 ... Read More

How to check if a number is a power of 2 in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:49:09

664 Views

A power of 2 is a number of the form 2n where n is an integerThe result of exponentiation with number two as the base and integer n as the exponent.n2n01122438416532Example 1 Live Democlass Program {    static void Main() {       Console.WriteLine(IsPowerOfTwo(9223372036854775809));       Console.WriteLine(IsPowerOfTwo(4));     ... Read More

How do you do a deep copy of an object in .NET?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:44:12

181 Views

Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original collection duplicatedDeep Copy is used to make a complete deep copy of the internal reference types.In another words a deep copy occurs when an object is copied along with ... Read More

What does the [Flags] Enum Attribute mean in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:41:57

657 Views

The Enum Flags is used to take an enumeration variable and allow it hold multiple values. It should be used whenever the enum represents a collection of flags, rather than representing a single valueUse the FlagsAttribute for an enumeration only if a bitwise operation (AND, OR, EXCLUSIVE OR) is to ... Read More

What is typeof, GetType or is in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:39:46

1K+ Views

Typeof()The type takes the Type and returns the Type of the argument.GetType()The GetType() method of array class in C# gets the Type of the current instance.isThe "is" keyword is used to check if an object can be casted to a specific type. The return type of the operation is Boolean.Example Live ... Read More

How to implement a Singleton design pattern in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Aug-2020 08:36:24

578 Views

Singleton Pattern belongs to Creational type patternSingleton design pattern is used when we need to ensure that only one object of a particular class is Instantiated. That single instance created is responsible to coordinate actions across the application.As part of the Implementation guidelines we need to ensure that only one ... Read More

Advertisements