
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
Found 2587 Articles for Csharp

454 Views
The Dictionary.Item[] property in C# is used to get or set the value associated with the specified key in the Dictionary.SyntaxFollowing is the syntax −public TValue this[TKey key] { get; set; }ExampleLet us now see an example to implement the Dictionary.Item[] property −using System; using System.Collections.Generic; public class Demo { public static void Main(){ Dictionary dict = new Dictionary(); dict.Add("One", "Chris"); dict.Add("Two", "Steve"); dict.Add("Three", "Messi"); dict.Add("Four", "Ryan"); dict.Add("Five", "Nathan"); Console.WriteLine("Count of elements = "+dict.Count); ... Read More

285 Views
The Dictionary.Add() method in C# is used to add a specified key and value to the dictionary.SyntaxFollowing is the syntax −public void Add (TKey key, TValue val);Above, the key parameter is the key, whereas Val is the value of the element.ExampleLet us now see an example to implement the Dictionary.Add() method −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

331 Views
The DateTimeOffset.AddSeconds() method in C# is used to return a new DateTimeOffset object that adds a specified number of whole and fractional seconds to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddSeconds (double val);Above, Val is the number of seconds to be added. To subtract seconds, set a negative value.ExampleLet us now see an example to implement the DateTimeOffset.AddSeconds() method −using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 10, 11, 7, 10, 20, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset (before adding seconds) = ... Read More

344 Views
The DateTimeOffset.AddMonths() method in C# is used to add a specified number of months to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddMonths (int val);Above, Val is the number of months to be added. For subtracting months, set a negative value.ExampleLet us now see an example to implement the DateTimeOffset.AddMonths() method −using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 08, 10, 4, 20, 10, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset (before adding months) = {0}", dateTimeOffset); DateTimeOffset res = dateTimeOffset.AddMonths(3); ... Read More

405 Views
The DateTimeOffset.AddMinutes() method in C# is used to adds a specified number of whole and fractional minutes to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddMinutes (double val);Above, Val is the number of minutes to be added. To subtract, set a negative value for minutes.ExampleLet us now see an example to implement the DateTimeOffset.AddMinutes() method −using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 08, 10, 4, 20, 10, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset (before adding minutes) = {0}", dateTimeOffset); ... Read More

322 Views
The Byte.Equals(Byte) method in C# returns a value indicating whether this instance and a specified Byte object represent the same value.SyntaxFollowing is the syntax −public bool Equals (byte ob);Above, ob is an object to compare to this instance.ExampleLet us now see an example to implement the Byte.Equals(Byte) method −using System; public class Demo { public static void Main(){ byte b1, b2; b1 = 5; b2 = 5; if (b1.Equals(b2)) Console.Write("b1 = b2"); else Console.Write("b1 is not equal to b2"); } }OutputThis will produce the following output −b1 = b2

107 Views
The Byte.CompareTo(Object) method in C# is used to compare this instance to a specified object and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (object val);Above, Val is an object to compare or null.The return value is less than zero if the current instance is less than the value. It’s zero, if the current instance is equal to value, whereas return value is more than zero if the current instance is more than value.ExampleLet us now see an example to implement the Byte.CompareTo(Object) method −using System; public class Demo { public static void Main(){ ... Read More

145 Views
The Byte.CompareTo(Byte) method in C# is used to compare this instance to a specified 8-bit unsigned integer and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (byte val);Above, the parameter value is an 8-bit unsigned integer to compare.The return value is less than zero if the current instance is less than the value. It’s zero, if the current instance is equal to value, whereas return value is more than zero if the current instance is more than value.ExampleLet us now see an example to implement the Byte.CompareTo(Byte) method −using System; public class Demo { ... Read More

2K+ Views
The Boolean.TryParse() method in C# is used to convert the specified string representation of a logical value to its Boolean equivalent.SyntaxFollowing is the syntax −public static bool TryParse (string val out bool result);ExampleLet us now see an example to implement the Boolean.TryParse() method −using System; public class Demo { public static void Main(){ bool val; bool flag; val = Boolean.TryParse("true", out flag); Console.WriteLine("Result = "+val); } }OutputThis will produce the following output −Result = TrueExampleLet us now see another example to implement the Boolean.TryParse() method −using ... Read More

991 Views
The DateTime.ToUniversalTime() method in C# is used to convert the value of the current DateTime object to Coordinated Universal Time (UTC).SyntaxFollowing is the syntax −public DateTime ToUniversalTime ();ExampleLet us now see an example to implement the DateTime.ToUniversalTime() method −using System; public class Demo { public static void Main() { DateTime d = new DateTime(2019, 12, 11, 7, 11, 25); Console.WriteLine("Date = {0}", d); DateTime res = d.ToUniversalTime(); Console.WriteLine("String representation = {0}", res); } }OutputThis will produce the following output −Date = 11/11/2019 7:11:25 AM String representation ... Read More