Sign Up

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

Have an account? Sign In

Have an account? Sign In Now

Sign In

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

Sign Up Here

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.

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 372483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:12:54+00:00 2026-05-12T14:12:54+00:00

Finding myself in the situation where I have a method with this signature void

  • 0

Finding myself in the situation where I have a method with this signature

void DoSomething(IEnumerable<T> before, IEnumerable<T> after)

I find myself often having to call it when I’ve just got one element and not IEnumerable.

I thought of adding the three overloads, but that doesn’t help when one of the arguments is null.

So I thought I could just ‘wrap up’ my single element in an IEnumerable and send it on, but I can’t find anything on Enumerable which looks like what I want (maybe I’m not looking hard enough).

So I’m looking at something like this

    public static IEnumerable<T> EnumerableUnit<T>(T item)
    {
        if(item != null) yield return item;
    }

Is this a good idea? Or is there something better I should be doing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:12:54+00:00Added an answer on May 12, 2026 at 2:12 pm

    This might help:

    new[]{obj}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been finding myself using the Chain of Responsibility pattern often (3 times
Using a proprietary framework, I am frequently finding myself in the situation where I
I find myself in a difficult situation. We're working on an ASP.NET MVC 2
I'm finding myself using it each time before a commit. Is it right? If
I'm finding myself writing a lot of classes with constructors like this: class MyClass(object):
I am finding myself repeating typing many strftime which I defined. Having watch Ryan
I'm finding myself in need of combining several instances of the same type. This
After thinking that I finally figured git out, I'm now finding myself super-confused about
Have gotten the foundation in place, but now, finding myself wanting to play around
I'm finding myself writing this line for every query: using ( MyDataModel thisDataContext =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.