Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
How to check if List empty or null in C#
Check if the list is empty in C# You can check whether the list is empty or not in many ways. The first approach is to check for null, and if the count is greater than zero Example: if (strList != null && strList.Count > 0) { Console.WriteLine("The List has " + strList.Count + " reRead more
Check if the list is empty in C#
You can check whether the list is empty or not in many ways.
Example:
Output:
Example:
Output:
Do you find it helpful? Share to Spread Knowledge
See lessRemove the extension from a file name in C#
You can use Path.GetFileNameWithoutExtension: DirectoryInfo dirInfo = new DirectoryInfo(currentDirName); FileInfo[] smFiles = dirInfo.GetFiles("*.txt"); foreach (FileInfo file in smFiles) { builder.Append(Path.GetFileNameWithoutExtension(file.Name)); builder.Append(", "); }
You can use Path.GetFileNameWithoutExtension:
DirectoryInfo dirInfo = new DirectoryInfo(currentDirName);
FileInfo[] smFiles = dirInfo.GetFiles(“*.txt”);
foreach (FileInfo file in smFiles)
See less{
builder.Append(Path.GetFileNameWithoutExtension(file.Name));
builder.Append(“, “);
}
How to get last 4 characters from string in C#?
use the substring() method to get the last 4 characters str.Substring(str.Length - 4);
use the substring() method to get the last 4 characters
str.Substring(str.Length – 4);
See less