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
Articles by AmitDiwan
Page 203 of 840
TimeSpan.FromTicks() Method in C#
The TimeSpan.FromTicks() method in C# is used to create a TimeSpan object that represents a specified time duration in ticks. A tick represents one hundred nanoseconds or one ten-millionth of a second, making it the smallest unit of time measurement in .NET. Syntax Following is the syntax for the TimeSpan.FromTicks() method − public static TimeSpan FromTicks(long val); Parameters The method accepts the following parameter − val − A long integer representing the number of ticks. Each tick equals 100 nanoseconds. Return Value Returns a TimeSpan object that represents ...
Read MoreCapacity of a List in C#
The Capacity property of a List in C# represents the total number of elements the internal array can hold before needing to be resized. This is different from the Count property, which represents the actual number of elements currently stored in the list. Understanding capacity is important for performance optimization, as the list automatically doubles its capacity when more space is needed, which involves allocating a new array and copying existing elements. Syntax Following is the syntax to get the capacity of a list − int capacity = listName.Capacity; You can also set ...
Read MoreConvert the value of the current DateTime object to UTC in C#
To convert the value of the current DateTime object to Coordinated Universal Time (UTC), C# provides the ToUniversalTime() method. This method converts a local time or unspecified DateTime to its equivalent UTC representation. Syntax Following is the syntax for the ToUniversalTime() method − DateTime utcDateTime = localDateTime.ToUniversalTime(); Return Value The ToUniversalTime() method returns a new DateTime object that represents the UTC equivalent of the original DateTime. If the original DateTime's Kind property is DateTimeKind.Utc, it returns the same value unchanged. Local Time to UTC Conversion ...
Read MoreGet the hash code for the current Decimal instance in C#
The GetHashCode() method in C# returns a 32-bit signed integer hash code for the current Decimal instance. This hash code is used internally by collections like HashSet and Dictionary to efficiently store and retrieve decimal values. Hash codes are essential for the proper functioning of hash-based collections, as they provide a quick way to categorize and locate objects. Two Decimal instances that are equal will always return the same hash code, but different decimal values may occasionally produce the same hash code (hash collision). Syntax Following is the syntax for getting the hash code of a Decimal ...
Read MoreC# String Properties
The String class in C# provides essential properties that allow you to access and examine string data. The two primary properties are Chars for accessing individual characters and Length for determining the string size. String Properties Following are the key properties of the String class in C# − Property Description Chars Gets the Char object at a specified position in the current String object using indexer syntax. Length Gets the number of characters in the current String object. Syntax Following is the syntax ...
Read MoreDifference Between C# and C++
C# and C++ are both powerful programming languages, but they serve different purposes and have distinct characteristics. Understanding their differences helps developers choose the right language for their projects. What is C#? C# is a general-purpose object-oriented programming language developed by Anders Hejlsberg and his team at Microsoft. It is pronounced as 'C sharp' and is considered a pure object-oriented programming language that runs on the .NET framework. Key characteristics of C# include − Automatic memory management through garbage collection Platform-specific (primarily Windows, though .NET Core enables cross-platform development) No ...
Read MoreThread.CurrentThread Property in C#
The Thread.CurrentThread property in C# is used to get a reference to the currently executing thread. This static property returns the Thread object representing the thread that is currently running, allowing you to access information about the current thread's state, name, ID, and other properties. Syntax The syntax for accessing the current thread is as follows − public static System.Threading.Thread CurrentThread { get; } Return Value This property returns a Thread object that represents the currently executing thread. Through this object, you can access various thread properties and methods. Using Thread.CurrentThread for ...
Read MoreConvert Decimal to equivalent 8-bit unsigned integer in C#
To convert a Decimal value to an equivalent 8-bit unsigned integer (byte), C# provides the Decimal.ToByte() method. This method truncates the decimal portion and converts the integer part to a byte value, which ranges from 0 to 255. The conversion follows banker's rounding rules for values exactly between two integers, and throws an OverflowException if the decimal value is outside the valid byte range. Syntax Following is the syntax for converting decimal to byte − byte result = Decimal.ToByte(decimalValue); Parameters decimalValue − The decimal number to convert to a byte. Must ...
Read MoreStringBuilder.Chars[] Property in C#
The StringBuilder.Chars[] property in C# provides indexed access to individual characters within a StringBuilder instance. This property allows you to both get and set characters at specific positions, making it useful for character-level manipulations without converting the entire StringBuilder to a string. Syntax Following is the syntax for the StringBuilder.Chars[] property − public char this[int index] { get; set; } Parameters index − The zero-based position of the character to get or set. Must be within the bounds of the StringBuilder (0 to Length-1). Return Value Returns ...
Read MoreCheck whether the Unicode character is a separator character in C#
The Char.IsSeparator() method in C# determines whether a Unicode character belongs to the separator category. Unicode separator characters are used to separate words, lines, or paragraphs in text, such as spaces, line separators, and paragraph separators. Syntax Following is the syntax for the Char.IsSeparator() method − public static bool IsSeparator(char c) public static bool IsSeparator(string s, int index) Parameters c − The Unicode character to evaluate. s − A string containing the character to evaluate. index − The position of the character to evaluate in the string. Return Value ...
Read More