- 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
Samual Sam has Published 2492 Articles
Samual Sam
674 Views
To get the last access time of a file in C#, use the LastAccessTime() method.For this, use the FileInfo as well as DateTime classes.Create an object of each −FileInfo file = new FileInfo("new.txt"); DateTime dt = file.CreationTime; dt = file.LastAccessTime;Let us see the complete code −Example Live Demousing System.IO; using System; ... Read More
Samual Sam
100 Views
Set lowercase suffixes for literals such as u, l, ul, f, etc.// l for long long a = 29876l;It can be used on literal numbers as well. It tells the compiler that the literal is of a specific type.The following is an example −Example Live Demousing System.IO; using System; public class ... Read More
Samual Sam
3K+ Views
ElementAt() is a System.Linq method in C# that is used to get and display element at a particular index.The following is our string array −string[] arr = { "One", "Two", "Three", "Four", "Five" };Now to get an element at index 0, use the ElementAt() method −arr.ElementAt(0);The following is the complete ... Read More
Samual Sam
284 Views
SkipWhile skips an element when a condition is matched.For example, use the following if you want to skip all even elements −ele => ele %2 == 0The following is an example wherein all the even elements are skipped and only the odd elements are displayed −Example Live Demousing System.IO; using System; ... Read More
Samual Sam
8K+ Views
Use the Take() method to get the first individual number of elements in C#.Firstly, set a list and add elements −List myList = new List(); myList.Add("One"); myList.Add("Two"); myList.Add("Three"); myList.Add("Four"); myList.Add("Five"); myList.Add("Six");Now, use the Take() method to get the elements from the list. Add the number of the elements you want ... Read More
Samual Sam
71 Views
Use the ContainsValue() method in C# to search for a value in a Dictionary.Create a Dictionary and add elements −Dictionary d = new Dictionary(); d.Add("keyboard", "One"); d.Add("mouse", "Two");Now, use the ContainsValue() method to find a particular value −d.ContainsValue("Two");The following is the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; ... Read More
Samual Sam
2K+ Views
To compare, ignoring case, use the case-insensitive Dictionary.While declaring a Dictionary, set the following property to get case-insensitive Dictionary −StringComparer.OrdinalIgnoreCaseAdd the property like this −Dictionary dict = new Dictionary (StringComparer.OrdinalIgnoreCase);Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Program { public static void Main() ... Read More
Samual Sam
4K+ Views
Use WriteAllLines method to write an array to a file.Firstly, set a string array −string[] stringArray = new string[] { "one", "two", "three" };Now, use the WriteAllLines method to add the above array to a file −File.WriteAllLines("new.txt", stringArray);Here is the complete code −Example Live Demousing System.IO; using System; ... Read More
Samual Sam
96 Views
Firstly, use the DirectoryInfo that operates on Directories. The parameter set in it is the file path −DirectoryInfo dir = new DirectoryInfo(@"D:ew\");To get the name of the directory, use the Name property −dir.NameThe following is the code to display the name of the directory −Example Live Demousing System.IO; using System; public ... Read More
Samual Sam
136 Views
To get information about a file means to get what all attributes are set for that particular file. For example, a file can be normal, hidden, archived, etc.Firstly, use the FileInfo class −FileInfo info = new FileInfo("hello.txt");Now, use FileAttributes to get information about a file −FileAttributes attr = info.Attributes;The following ... Read More