- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 34489 Articles for Programming
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
664 Views
Timespan shows the length of time.To get the maximum value of TimeSpan, use the following property.TimeSpan.MaxValueExample Live Demousing System; using System.Linq; public class Demo { public static void Main() { Console.WriteLine(TimeSpan.MaxValue); } }Output10675199.02:48:05.4775807
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
377 Views
Timespan shows the length of time.To get the minimum value of TimeSpan, use the following property.TimeSpan.MinValueExample Live Demousing System; using System.Linq; public class Demo { public static void Main() { Console.WriteLine(TimeSpan.MinValue); } }Output-10675199.02:48:05.4775808
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
117 Views
Use the TakeLast() method to return elements from the end of an array.Let us first declare and initialize an array.int[] prod = { 110, 290, 340, 540, 456, 698, 765, 789};Now, let’s get the last three elements.IEnumerable units = prod.AsQueryable().TakeLast(3);Let us see the complete code.Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { int[] prod = { 110, 290, 340, 540, 456, 698, 765, 789}; // value of last three products IEnumerable units = prod.AsQueryable().TakeLast(3); foreach (int res in units) { Console.WriteLine(res); } } }Output698 765 789
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
4K+ Views
To set the max value for a Date, use the DateTime property MaxValue.DateTime max = DateTime.MaxValue;Now, display the value of max to get the maximum value of a date as shown below.Example Live Demousing System; using System.Linq; public class Demo { public static void Main() { DateTime max = DateTime.MaxValue; Console.WriteLine(max); } }Output12/31/9999 11:59:59 PM
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
320 Views
The Generate Date Short Time format specifier is a combination of the short date ("d") and short time ("t") patterns, separated by a space.Set a date using DateTime.DateTime dt = new DateTime(2018, 10, 2, 7, 59, 20);Now, use the (“g”) format specifier.dt.ToString("g", DateTimeFormatInfo.InvariantInfo));Example Live Demousing System; using System.Globalization; class Demo { static void Main() { DateTime dt = new DateTime(2018, 10, 2, 7, 59, 20); Console.WriteLine(dt.ToString("g", DateTimeFormatInfo.InvariantInfo)); Console.WriteLine(dt.ToString("g", CultureInfo.CreateSpecificCulture("en-us"))); } }Output10/02/2018 07:59 10/2/2018 7:59 AM
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Set a DateTime to its minimum value.DateTime.MinValue;The above will display the minimum value i.e.1/1/0001Let us see how to display the minimum value and avoid adding null to a date to initialize it as empty.Example Live Demousing System; using System.Linq; public class Demo { public static void Main() { DateTime dt = DateTime.MinValue; Console.WriteLine(dt); } }Output1/1/0001 12:00:00 AM
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
10K+ Views
To display current month, firstly use “Now“ to get the current date.DateTime dt = DateTime.Now;Now, use the Month property to get the current month.dt.MonthLet us see the complete code.Example Live Demousing System; using System.Linq; public class Demo { public static void Main() { DateTime dt = DateTime.Now; Console.WriteLine(dt.Month); } }Output9To display current month’s name.Example Live Demousing System; using System.Linq; public class Demo { public static void Main() { DateTime dt = DateTime.Now; Console.WriteLine(dt.ToString("MMM")); } }OutputSep
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
13K+ Views
Use DateTime. DayOfWeek property to display the current day of week.DayOfWeek wk = DateTime.Today.DayOfWeek;Now, displaying “wk” would give you the current day of the week.Let us see the complete code to get the current day of week.Example Live Demousing System; using System.Linq; public class Demo { public static void Main() { DayOfWeek wk = DateTime.Today.DayOfWeek; Console.WriteLine(wk); } }OutputWednesday
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
266 Views
Use All() Method to check whether the elements of a sequence satisfy a condition or not. Even if one of the element do not satisfy the set condition, the All() method returns False.To set conditions, use Lambda Expressions. Below shows a condition to check whether all the elements are greater than 20 or not.myArr.AsQueryable().All(val => val > 20);Let us see an example.Example Live Demousing System; using System.Linq; class Demo { static void Main() { int[] myArr = {7, 15, 22, 30, 40}; // checking if all the array elements are greater than 20 bool res = myArr.AsQueryable().All(val => val > 20); Console.WriteLine(res); } }OutputFalse
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
345 Views
Use the AsEnumerable() method to cast a type to its IEnumerable equivalent. It is an extension method.For our example, we have set an array.int[] myArr = new int[10]; myArr[0] = 1; myArr[1] = 2; myArr[2] = 3; myArr[3] = 4; myArr[4] = 5;Now, we have used the AsEnumerable() method to cast.myArr.AsEnumerable();Example Live Demousing System; using System.Linq; class Demo { static void Main() { int[] myArr = new int[10]; myArr[0] = 1; myArr[1] = 2; myArr[2] = 3; myArr[3] = 4; myArr[4] = 5; myArr[5] = 6; myArr[6] = 7; myArr[7] = 8; myArr[8] = 9; myArr[9] = 10; // AsEnumerable var a = myArr.AsEnumerable(); // Displaying foreach (var item in a) { Console.WriteLine(item); } } }Output1 2 3 4 5 6 7 8 9 10