Sign Up

Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In
Continue with Google
or use


Have an account? Sign In Now

Sign In

Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.

Sign Up Here
Continue with Google
or use

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

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.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

C#

Share
  • Facebook
0 Followers
3 Answers
20 Questions
Home/C#
  • Recent Questions
  • Answers
  • No Answers
  1. Asked: September 8, 2021In: C#

    How to check if List empty or null in C#

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 16, 2022 at 8:18 am
    This answer was edited.

    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.

    • 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 + " records"); 
    }

    Output:

    The List has 10 records

     

    • The second approach is to use the LINQ method called “.any()”

     

    Example:

    if ((strList != null) && (!strList .Any()))
    {
    Console.WriteLine("The List has more than one record"); 
    }

    Output:

    The List has more than one record

    Do you find it helpful? Share to Spread Knowledge

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  2. Asked: September 9, 2021In: C#

    Remove the extension from a file name in C#

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 10, 2021 at 12:32 pm

    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)
    {
    builder.Append(Path.GetFileNameWithoutExtension(file.Name));
    builder.Append(“, “);
    }

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  3. Asked: September 9, 2021In: C#

    How to get last 4 characters from string in C#?

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 10, 2021 at 12:08 pm

    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
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp

Sidebar

Adv 250x250

Explore

  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

Footer

Oraask

About

Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy
  • Terms & Conditions

Follow

Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

© 2019 Oraask. All Rights Reserved
With Love by Oraask.