Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Csharp Articles
Page 189 of 196
DateTime.ToShortTimeString() Method in C#
The DateTime.ToShortTimeString() method in C# converts a DateTime object to its equivalent short time string representation. This method formats the time portion of the date using the current system culture's short time pattern, typically showing hours and minutes in 12-hour or 24-hour format. Syntax Following is the syntax − public string ToShortTimeString(); Return Value Returns a string that contains the short time string representation of the current DateTime object. Using ToShortTimeString() with Current DateTime This example demonstrates how to use ToShortTimeString() with the current system time and shows the culture-specific formatting ...
Read MoreDateTime.ToString() Method in C#
The DateTime.ToString() method in C# converts a DateTime object to its string representation. This method provides multiple overloads to format the date and time according to different requirements using format strings and culture-specific formatting. Syntax The DateTime.ToString() method has four overloads − ToString() ToString(String) ToString(IFormatProvider) ToString(String, IFormatProvider) Parameters format − A standard or custom date and time format string. provider − An object that supplies culture-specific formatting information. Return Value Returns a string representation of the current DateTime object formatted according to the specified format string and culture information. ...
Read MoreDateTime.ToUniversalTime() Method in C#
The DateTime.ToUniversalTime() method in C# is used to convert the value of the current DateTime object to Coordinated Universal Time (UTC). This method is essential when working with applications that handle multiple time zones or need to store timestamps in a universal format. Syntax Following is the syntax − public DateTime ToUniversalTime(); Return Value Returns a DateTime object whose value is equivalent to the current DateTime object converted to UTC. If the current DateTime object represents a local time, it is converted to UTC using the system's time zone information. If it already ...
Read MoreBoolean.TryParse() Method in C#
The Boolean.TryParse() method in C# safely converts a string representation of a logical value to its Boolean equivalent. Unlike Boolean.Parse(), this method returns true if the conversion succeeds and false if it fails, without throwing exceptions. Syntax Following is the syntax − public static bool TryParse(string value, out bool result); Parameters value − A string containing the value to convert. result − When this method returns, contains the Boolean value equivalent to the value contained in value, if the conversion succeeded, or false if the conversion failed. ...
Read MoreByte.CompareTo(Byte) Method in C#
The Byte.CompareTo(Byte) method in C# is used to compare the current byte instance to a specified 8-bit unsigned integer and returns an indication of their relative values. This method is useful for sorting operations and determining the relative ordering of byte values. Syntax Following is the syntax − public int CompareTo(byte value); Parameters value: An 8-bit unsigned integer to compare with the current instance. Return Value The method returns an integer that indicates the relative values of the compared instances: Less than zero: The current instance is less ...
Read MoreByte.CompareTo(Object) Method in C#
The Byte.CompareTo(Object) method in C# compares the current byte instance to a specified object and returns an integer that indicates their relative values. This method is useful for sorting operations and determining the ordering relationship between byte values. Syntax Following is the syntax − public int CompareTo(object val); Parameters val − An object to compare, or null. Return Value The method returns an integer with the following meaning − Less than zero − The current instance is less than the value. Zero − The current instance ...
Read MoreDateTimeOffset.AddMinutes() Method in C#
The DateTimeOffset.AddMinutes() method in C# adds a specified number of whole and fractional minutes to a DateTimeOffset instance. This method returns a new DateTimeOffset object with the updated time while preserving the original offset from UTC. The method is particularly useful when working with time-zone aware calculations, as it maintains the timezone offset information throughout the operation. Syntax Following is the syntax − public DateTimeOffset AddMinutes(double minutes); Parameters minutes − A double value representing the number of minutes to add. Can be positive (to add) or negative (to subtract). Fractional values ...
Read MoreDateTimeOffset.AddMonths() Method in C#
The DateTimeOffset.AddMonths() method in C# is used to add a specified number of months to a DateTimeOffset instance. This method returns a new DateTimeOffset object with the month value adjusted while preserving the time zone offset information. Syntax Following is the syntax for the AddMonths() method − public DateTimeOffset AddMonths(int months); Parameters months − An integer representing the number of months to add. Use a positive value to add months or a negative value to subtract months. Return Value Returns a new DateTimeOffset object that represents the date and time that ...
Read MoreDateTimeOffset.AddSeconds() Method in C#
The DateTimeOffset.AddSeconds() method in C# returns a new DateTimeOffset object that adds a specified number of whole and fractional seconds to the value of the current instance. This method is useful for time calculations where you need to preserve timezone offset information. Syntax Following is the syntax − public DateTimeOffset AddSeconds(double val); Parameters val − A double representing the number of seconds to add. It can be positive (to add seconds) or negative (to subtract seconds). Fractional values are allowed. Return Value Returns a new DateTimeOffset object whose value is the ...
Read MoreDictionary.Add() Method in C#
The Dictionary.Add() method in C# is used to add a specified key-value pair to the dictionary. This method adds elements to the dictionary and throws an exception if you try to add a duplicate key. Syntax Following is the syntax − public void Add(TKey key, TValue value) Parameters key − The key of the element to add. Cannot be null. value − The value of the element to add. Can be null for reference types. Return Value This method does not return any value. It ...
Read More