snipt

Ctrl+h for KB shortcuts

C#

general linq query to look up string in a list of arrays

1
2
3
var query = from row in data
            where row[0].Contains(searchObject.ToString())
            select row;
https://snipt.net/embed/34b905410c08c7a6277900820e058926/
/raw/34b905410c08c7a6277900820e058926/
34b905410c08c7a6277900820e058926
csharp
C#
3
2019-06-24T19:52:23
True
False
False
/api/public/snipt/3326/
general-linq-query-to-look-up-string-in-a-list-of-arrays
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kt">var</span> <span class="n">query</span> <span class="p">=</span> <span class="k">from</span> <span class="n">row</span> <span class="k">in</span> <span class="n">data</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">where</span> <span class="n">row</span><span class="p">[</span><span class="m">0</span><span class="p">].</span><span class="n">Contains</span><span class="p">(</span><span class="n">searchObject</span><span class="p">.</span><span class="n">ToString</span><span class="p">())</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">select</span> <span class="n">row</span><span class="p">;</span> </span></pre></div> </td></tr></table>
c#, linq