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 Samual Sam
Page 26 of 151
FormatException in C#
A FormatException is thrown when the format of an argument is invalid or cannot be converted to the expected data type. This commonly occurs when attempting to parse a string that doesn't match the expected format for numeric or date types. Common Scenarios FormatException typically occurs in these situations − Parsing a non-numeric string as a number using int.Parse(), double.Parse(), etc. Converting a string with decimal points to an integer Parsing invalid date formats using DateTime.Parse() Using incorrect format specifiers in string formatting Using int.Parse() with ...
Read MoreLog functions in C#
With C#, you can easily work with logarithms using the Math class. It provides several methods to calculate logarithms with different bases, including natural logarithms (base e) and common logarithms (base 10). Available Log Methods Method Description Log(Double) Returns the natural (base e) logarithm of a specified number. Log(Double, Double) Returns the logarithm of a specified number in a specified base. Log10(Double) Returns the base 10 logarithm of a specified number. Syntax Following are the syntax forms for logarithm methods − ...
Read MoreMedium-Earth Orbit Satellites
This article appears to be about satellite orbits, not C# programming. As a C# tutorial enhancement specialist, I can only improve C# programming articles for TutorialsPoint.com. Please provide a C# programming article that needs improvement, such as topics related to: C# language features (classes, methods, properties, etc.) .NET Framework concepts Object-oriented programming in C# C# syntax and programming constructs C# libraries and APIs I'll be happy to enhance any C# programming tutorial following the TutorialsPoint standards with proper code formatting, examples, and structure.
Read MoreC# program to Reverse words in a string
In C#, reversing words in a string means reversing each individual word while keeping the words in their original positions. For example, "Hello World" becomes "olleH dlroW" where each word is reversed but the word order remains the same. Syntax Using LINQ with Split(), Select(), and Reverse() methods − string result = string.Join(" ", str.Split(' ').Select(word => new string(word.Reverse().ToArray()))); Using a traditional loop approach − string[] words = str.Split(' '); for (int i = 0; i < words.Length; i++) { words[i] = ReverseWord(words[i]); } string result = string.Join(" ...
Read MoreC# Linq First() Method
The First() method in C# LINQ is used to return the first element from a collection such as arrays, lists, or any IEnumerable sequence. It throws an exception if the collection is empty. Syntax Following is the syntax for the First() method − collection.First() collection.First(predicate) Parameters predicate (optional) − A function to test each element for a condition. Return Value Returns the first element in the collection or the first element that satisfies the condition. Throws InvalidOperationException if no element is found. Using First() Without Predicate The ...
Read MoreWhat are unary operators in C#?
Unary operators in C# are operators that operate on a single operand. They perform various operations such as incrementing, decrementing, negating, or getting the size of a data type. Complete List of Unary Operators Operator Name Description + Unary plus Indicates positive value (rarely used) - Unary minus Negates the value ! Logical NOT Inverts boolean value ~ Bitwise complement Inverts all bits ++ Increment Increases value by 1 -- Decrement Decreases value by 1 (type) Cast Converts to ...
Read MoreC# program to Illustrate Upper Triangular Matrix
An upper triangular matrix is a square matrix where all elements below the main diagonal are zero. In an upper triangular matrix, elements are preserved only on or above the main diagonal (where row index ≤ column index). Upper Triangular Matrix 1 2 3 4 0 5 6 7 0 0 8 9 0 0 0 10 Zero below diagonal Non-zero on/above diagonal Logic To display an upper triangular matrix, we use the condition i
Read MoreC# Program to pass Parameter to a Thread
To work with threads in C#, you need to add the System.Threading namespace. Passing parameters to threads allows you to send data from the main thread to worker threads, enabling more flexible and dynamic thread operations. Syntax Following is the syntax for creating a thread and passing a parameter − Thread thread = new Thread(ThreadMethod); thread.Start(parameter); The thread method must accept an object parameter − static void ThreadMethod(object parameter) { // cast parameter to appropriate type } Using Thread.Start() with a Parameter The Thread.Start(object) method accepts ...
Read MoreRepresent Int32 as a String in C#
The Int32 type in C# represents a 32-bit signed integer. To convert an Int32 value to its string representation, you can use the ToString() method. This method converts the numeric value into a readable string format. Syntax Following is the syntax for converting an Int32 to string using ToString() − int number = value; string result = number.ToString(); You can also use format specifiers with ToString() − string result = number.ToString("format"); Using ToString() Method Basic Conversion Example The simplest way to convert an Int32 to string is using ...
Read MoreC# Program to perform all Basic Arithmetic Operations
Basic arithmetic operators in C# allow you to perform mathematical calculations such as addition, subtraction, multiplication, division, and modulus operations. These operators work with numeric data types and form the foundation of mathematical computations in C#. Arithmetic Operators Operator Description + Adds two operands - Subtracts the second operand from the first * Multiplies both operands / Divides the numerator by denominator % Modulus operator returns the remainder after division ++ Increment operator increases integer value by one -- ...
Read More