Yes, LINQ to Objects supports this with Enumerable.Concat
:
var together = first.Concat(second);
NB: Should first
or second
be null you would receive a ArgumentNullException
. To avoid this & treat nulls as you would an empty set, use the null coalescing operator like so:
var together = (first ?? Enumerable.Empty<string>()).Concat(second ?? Enumerable.Empty<string>()); //amending `<string>` to the appropriate type
Related Contents:
- The order of elements in Dictionary
- Count the items from a IEnumerable without iterating?
- ReadOnlyCollection or IEnumerable for exposing member collections?
- How to get the index of an element in an IEnumerable?
- Pair-wise iteration in C# or sliding window enumerator
- Passing a single item as IEnumerable
- How to check if IEnumerable is null or empty?
- What is the difference between IEnumerator and IEnumerable? [duplicate]
- When a class is inherited from List, XmlSerializer doesn’t serialize other attributes
- Pair-wise iteration in C#, or sliding window enumerator
- IEnumerable to string [duplicate]
- IEnumerable vs IReadonlyCollection vs ReadonlyCollection for exposing a list member
- Map two lists into a dictionary in C#
- Difference between IEnumerable Count() and Length
- Is there an IEnumerable implementation that only iterates over it’s source (e.g. LINQ) once?
- IEnumerable and order
- How and when to use ‘async’ and ‘await’
- What is the best way to check for Internet connectivity using .NET?
- Does using “new” on a struct allocate it on the heap or stack?
- Update .NET web service to use TLS 1.2
- ServiceStack Request DTO design
- Detect target framework version at compile time
- When should “SqlDbType” and “size” be used when adding SqlCommand Parameters?
- Could not find a part of the path … bin\roslyn\csc.exe
- How do I run a simple bit of code in a new thread?
- Does .NET provide an easy way convert bytes to KB, MB, GB, etc.?
- String format currency
- What’s the difference between IEquatable and just overriding Object.Equals()?
- How do I truncate a .NET string?
- convert double to int
- How to submit http form using C#
- Why isn’t my public property serialized by the XmlSerializer?
- How do you UrlEncode without using System.Web?
- How to prevent blank xmlns attributes in output from .NET’s XmlDocument?
- Get text/value from textbox after value/text changed server side
- Extension methods syntax vs query syntax
- Getting hash of a list of strings regardless of order
- Adding and removing users from Active Directory groups in .NET
- Record a video of the screen using .NET technologies [closed]
- Best way to store encryption keys in .NET C#
- ILMerge Best Practices
- Is it possible to Embed Gecko or Webkit in a Windows Form just like a WebView?
- How to set a proxy for Webbrowser Control without effecting the SYSTEM/IE proxy
- How to find out if a property is an auto-implemented property with reflection?
- How to achieve remove_if functionality in .NET ConcurrentDictionary
- How to split string preserving whole words?
- saving state between program restarts
- C# operator overload for `+=`?
- read string from .resx file in C#
- Is it better to declare a variable inside or outside a loop?