Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 2112 of 2650
69 Views
The DateTimeOffset.AddYears() method in C# is used to add a specified number of years to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddYears (int val);Above, the Val parameter is the years to be added to the offset. To subtract, you need to set negative values.ExampleLet us now see an example to implement the DateTimeOffset.AddYears() method −using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 06, 09, 8, 20, 10, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset (before adding years) = {0}", dateTimeOffset); ... Read More
910 Views
The Math.Atan() method in C# is used to return the angle whose tan is the specified number. The number is a double value argument. The method returns an angle, θ, measured in radians, such that -Π/2 ≤θ≤Π/2.SyntaxFollowing is the syntax −public static double Atan(double num)ExampleLet us now see an example to implement the Math.Atan() method −using System; public class Demo { public static void Main(){ double val1 = 0.0; double val2 = 1.0; Console.WriteLine("Return value of {0} : {1}", val1, Math.Atan(val1)); Console.WriteLine("Return value of {0} : {1}", ... Read More
164 Views
The Math.Asin() method in C# is used to return the angle whose sine is the specified number. The number is a double value argument.SyntaxFollowing is the syntax −public static double Asin (double val);Above, Val is a number representing a sine. The value of Val must be greater than or equal to -1, but less than or equal to 1.ExampleLet us now see an example to implement Math.Asin() method −using System; public class Demo { public static void Main(){ double val1 = -0.0; double val2 = Double.PositiveInfinity; double val3 = Double.NaN; ... Read More
372 Views
The Math.Acos() method in C# returns the angle whose cosine is the specified number. This number is a double value argument. SyntaxThe syntax is as follows −public static double Acos (double val);Above, Val is the number representing a cosine, where Val must be greater than or equal to -1, but less than or equal to 1.ExampleLet us now see an example to implement Math.Acos() method −using System; public class Demo { public static void Main(){ double val1 = -0.0; double val2 = Double.PositiveInfinity; double val3 = Double.NaN; Console.WriteLine("Return ... Read More
16K+ Views
The Math.Abs() method in C# is used to return the absolute value of a specified number in C#. This specified number can be decimal, double, 16-bit signed integer, etc.ExampleLet us now see an example to implement the Math.abs() method to return the absolute value of double number −using System; class Demo { public static void Main(){ Double val1 = 30.40; Double val2 = Double.MinValue; Double val3 = Double.MaxValue; Console.WriteLine("Absolute value of {0} : {1}", val1, Math.Abs(val1)); Console.WriteLine("Absolute value of {0} : {1}", val2, Math.Abs(val2)); ... Read More
324 Views
The Dictionary.Values property in C# is used to fetch all the values in the Dictionary.SyntaxFollowing is the syntax −public System.Collections.Generic.Dictionary.KeyCollection Values{ get; }ExampleLet us now see an example to implement the Dictionary.Values property −using System; using System.Collections.Generic; public class Demo { public static void Main(){ Dictionary dict = new Dictionary(); dict.Add("One", "Kagido"); dict.Add("Two", "Ngidi"); dict.Add("Three", "Devillers"); dict.Add("Four", "Smith"); dict.Add("Five", "Warner"); Console.WriteLine("Count of elements = "+dict.Count); Console.WriteLine("Key/value pairs..."); foreach(KeyValuePair res in dict){ ... Read More
824 Views
Dictionary in C# is a collection of keys and values. It is a generic collection class in the System.Collection.Generics namespace.SyntaxFollowing is the syntax −public class DictionaryAbove, the key parameter is the type of keys in the dictionary, whereas TValue is the type of values.ExampleLet us now create a Dictionary and add some elements −using System; using System.Collections.Generic; public class Demo { public static void Main(){ Dictionary dict = new Dictionary(); dict.Add("One", "John"); dict.Add("Two", "Tom"); dict.Add("Three", "Jacob"); dict.Add("Four", "Kevin"); dict.Add("Five", "Nathan"); ... Read More
166 Views
The Convert.ToSByte() method in C# converts the specified string representation of a number to an equivalent 8-bit signed integer, using the specified culture-specific formatting information.SyntaxFollowing is the syntax −public static sbyte ToSByte (string val, IFormatProvider provider);Above, the parameter value is a string that contains the number to convert. A provider parameter is an object that supplies culture-specific formatting information.ExampleLet us now see an example to implement the Convert.ToSByte() method −using System; using System.Globalization; public class Demo { public static void Main(){ CultureInfo cultures = new CultureInfo("en-US"); String str = "-2"; ... Read More
2K+ Views
The Convert.ToDouble() method in C# converts the specified string representation of a number to an equivalent double-precision floating-point number, using the specified culture-specific formatting information.SyntaxFollowing is the syntax −public static double ToDouble (string val, IFormatProvider provider);Above, the value value is a string that contains the number to convert, whereas the provider is an object that supplies culture-specific formatting information.ExampleLet us now see an example to implement the Convert.ToDouble() method −using System; using System.Globalization; public class Demo { public static void Main(){ String val = "876876, 878"; NumberFormatInfo formatProvider = new NumberFormatInfo(); ... Read More
7K+ Views
The DateTime.AddHours() method in C# is used to add the specified number of hours to the value of this instance. This method returns a new DateTime.SyntaxFollowing is the syntax −public DateTime AddHours (double hrs);Above, hrs are the number of hours to be added. The value can be negative to subtract the hours.ExampleLet us now see an example to implement the DateTime.AddHours() methodusing System; public class Demo { public static void Main(){ DateTime d1 = new DateTime(2019, 11, 2, 9, 0, 10); DateTime d2 = d1.AddHours(2); System.Console.WriteLine("Initial DateTime = {0:dd} {0:y}, ... Read More