- 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 34486 Articles for Programming
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
6K+ Views
Firstly, get the current date.DateTime.TodayNow, use AddDays() method to add days to the current date. Here, we are adding 10 days to the current date.DateTime.Today.AddDays(10)Let us see the complete code −Example Live Demousing System; using System.Linq; public class Demo { public static void Main() { Console.WriteLine("Today = {0}", DateTime.Today); Console.WriteLine("Add 10 Days = {0}", DateTime.Today.AddDays(10)); } }OutputToday = 9/11/2018 12:00:00 AM Add 10 Days = 9/21/2018 12:00:00 AM
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
840 Views
Convert a specified value to a single-precision floating-point number using the Convert.ToSingle() method in C#.Here is our bool −bool boolVal = false;Now, let us use the ToSingle() method to convert the value to a single precision floating-point.float floatVal; floatVal = Convert.ToSingle(boolVal);Example Live Demousing System; public class Demo { public static void Main() { bool boolVal = false; float floatVal; floatVal = Convert.ToSingle(boolVal); Console.WriteLine("Converted {0} to {1}", boolVal, floatVal); } }OutputConverted False to 0
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
134 Views
The Full Date Short Time standard format specifier represents a combination of the long date ("D") and short time ("t") patterns.UseDateTime to set the date.DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0);Now, use the (“f”) format specifier like this −myDate.ToString("f", CultureInfo.CreateSpecificCulture("en-US"))The following is an example −Example Live Demousing System; using System.Globalization; class Demo { static void Main() { DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0); Console.WriteLine(myDate.ToString("f",CultureInfo.CreateSpecificCulture("en-US"))); } }OutputWednesday, August 29, 2018 1:10 AM
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
351 Views
The Long Time format specifier represents a custom date and time format string.It is defined by DateTimeFormatInfo.LongTimePattern property.The custom format string.HH:mm:ssExample Live Demousing System; using System.Globalization; class Demo { static void Main() { DateTime date = new DateTime(2018, 9, 9, 8, 15, 30); Console.WriteLine(date.ToString("T", CultureInfo.CreateSpecificCulture("en-us"))); } }Output8:15:30 AM
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
547 Views
This method returns true if the entered string has only whitespace characters or is null.Let’s say you are checking for whitespace character.bool val1 = string.IsNullOrWhiteSpace(“ “);The above returns True, since the string is a whitespace character. In the same way, check it for null using the IsNullOrWhiteSpace() method.Here is the entire example that checks for null and whitespace −Exampleusing System; using System.IO; public class Demo { public static void Main() { bool val1 = string.IsNullOrWhiteSpace(“100”); bool val2 = string.IsNullOrWhiteSpace(" "); bool val3 = string.IsNullOrWhiteSpace(null); Console.WriteLine(val1); Console.WriteLine(val2); Console.WriteLine(val3); } }
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
This method returns true if the entered string has only whitespace characters or is null.Let say you checked for null value −bool val1 = string.IsNullOrWhiteSpace(null);The above returns True, since the string is “null”. In the same way, check it for whitespace character.Here is the entire example that checks for null and whitespace.Example Live Demousing System; using System.IO; public class Demo { public static void Main() { bool val1 = string.IsNullOrWhiteSpace(null); bool val2 = string.IsNullOrWhiteSpace(" "); bool val3 = string.IsNullOrWhiteSpace("5"); Console.WriteLine(val1); Console.WriteLine(val2); Console.WriteLine(val3); } }OutputTrue True False
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
333 Views
Firstly, set a LinkedList with nodes.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students);To add a node at the first position, use the AddFirst() method.list.AddFirst("Amit");Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students); foreach (var stu in list) { Console.WriteLine(stu); } // adding a node Console.WriteLine("LinkedList after adding a node at the first position..."); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
144 Views
Use ReadAllText() method to read all the lines of a file at once.Let’s say we have a file “hello.txt” with the following lines −One Two ThreeTo read the above file, add the path of the file as parameter.File.ReadAllText(myPath);Above, myPath had the file path.String myPath = "hello.txt";Let us see the complete code −Exampleusing System; using System.IO; public class Demo { public static void Main() { String myPath = "hello.txt"; String allLines; allLines = File.ReadAllText(myPath); Console.WriteLine(allLines); } }OutputThe following is the output −One Two Three
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
299 Views
If any of the following string appears in the format string and followed by at least one zero, then the number is formatted with an “E” or “e” in between the number and the exponent."E" "E+" "E-" "e" "e+" "e-"Example Live Demousing System; using System.Globalization; class Demo { static void Main() { double num = 9400; Console.WriteLine(num.ToString("0.###E+0", CultureInfo.InvariantCulture)); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:0.###E+0}", num)); Console.WriteLine(num.ToString("0.###E+000", CultureInfo.InvariantCulture)); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:0.###E+000}", num)); } }Output9.4E+3 9.4E+3 9.4E+003 9.4E+003
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
712 Views
Use File.Delete method to delete a file.Firstly, set the path of the file you want to delete.String myPath = @"C:\New\amit.txt";Now, use the File.Delete method to delete the file.File.Delete(myPath);The following is the complete code −Example Live Demousing System; using System.IO; public class Program { public static void Main() { String myPath = @"C:\New\amit.txt"; Console.WriteLine("Deleting File"); File.Delete(myPath); } }OutputDeleting File