Nizamuddin Siddiqui has Published 2307 Articles

What is the difference between FromBody and FromUri attributes in C# ASP.NETWebAPI?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:46:27

5K+ Views

When the ASP.NET Web API calls a method on a controller, it must set values for the parameters, a process called parameter binding.In order to bind a model (an action parameter), that would normally default to a formatter, from the URI we need to decorate it with [FromUri] attribute. FromUriAttribute ... Read More

What is the difference between Task.WhenAll() and Task.WaitAll() in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:40:59

7K+ Views

The Task.WaitAll blocks the current thread until all other tasks have completed execution. The Task.WhenAll method is used to create a task that will complete if and only if all the other tasks have completed.If we are using Task.WhenAll we will get a task object that isn’t complete. However, it ... Read More

How to download a file from a URL in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:37:22

7K+ Views

A file can be downloaded from a URL using web client. It is available in System.Net namespace.The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.The web client can be said as an application or web ... Read More

How to populate XDocument from String in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:35:17

1K+ Views

XML is a self-describing language and it gives the data as well as the rules to identify what information it contains. Like HTML, XML is a subset of SGML - Standard Generalized Markup Language.The XDocument class contains the information necessary for a valid XML document. This includes an XML declaration, ... Read More

How to get the name of the current executable in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:31:26

3K+ Views

There are several ways to get the name of the current executable in C#.Using System.AppDomain −Application domain provides isolation between code running in different app domains. App Domain is a logical container for code and data just like process and has separate memory space and access to resources. App domain ... Read More

How to get a path to the desktop for current user in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:27:58

4K+ Views

The desktop path of the current user can be fetched by using Environment.SpecialFolder. The Environment.SpecialFolder gets the path to the system special folder that is identified by the specified enumeration.string desktopPath =Environment.GetFolderPath(Environment.SpecialFolder.Desktop)The System.Environment Class provides information about the current environment and platform. The System.Environment Class uses to retrieve Environment variable ... Read More

What is the best data type to use for currency in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:24:37

5K+ Views

The best datatype to use for currency in C# is decimal. The decimal type is a 128-bit data type suitable for financial and monetary calculations. The decimal type can represent values ranging from 1.0 * 10^-28 to approximately 7.9 * 10^28 with 28-29 significant digits. To initialize a decimal variable, ... Read More

How to convert an integer to hexadecimal and vice versa in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:13:29

10K+ Views

Converting Integer to HexadecimalAn integer can be converted to a hexadecimal by using the string.ToString() extension method.Integer Value: 500 Hexadecimal Value: 1F4Converting Hexadecimal to Integer −A hexadecimal value can be converted to an integer using int.Parse or convert.ToInt32int.Parse − Converts the string representation of a number to its 32-bit signed ... Read More

How to validate an email address in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:08:58

5K+ Views

There are several ways to validate an email address in C#.System.Net.Mail −The System.Net.Mail namespace contains classes used to send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery.System.Text.RegularExpressions − Represents an immutable regular expression.Use the below expression@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1, 3}\.[0-9]{1, 3}\.[0-9]{1, 3}\.)|(([a-zA-Z0-9\-]+\.)+))([azA-Z]{2, 4}|[0-9]{1, 3})(\]?)$"We can use the MailAddress class ... Read More

How to replace multiple spaces with a single space in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 19-Aug-2020 11:06:06

3K+ Views

There are several ways to replace multiple spaces with single space in C#.String.Replace − Returns a new string in which all occurrences of a specified Unicode character or String in the current string are replaced with another specified Unicode character or String.Replace(String, String, Boolean, CultureInfo)String.Join Concatenates the elements of a ... Read More

Advertisements