VB.NET : LINQ

["?0?1w0*0|string-concat-vbnet;datetime-format-vbnet;do-while-vbnet;linq-vbnet;-vbnet|concat;dates",["F@dBTU","MAJAECBEMA","OOBCCSTUUUUTTUUUUYGDGDHDGDFOBOCBWSTTUUUUTTUUUU","ttwt.","Keyword","Array","Dictionary","List","String","ArrayList","Cast","Class","Concat","Console","DataTable","Dates","DateTime","Enum","File","For","Format","If","IndexOf","Lambda","LINQ","Nothing","Parse","Process","Property","Random","Regex","Replace","Select","Sort","Split","StringBuilder","Sub","Substring","While","ToArray."," The IEnumerable type can store collections of elements. But in VB.NET programs, we often want arrays\u2014not IEnumerable instances. We use the ToArray extension to convert any IEnumerable type to an array.","Example."," To begin, this program creates a new IEnumerable instance with ten elements in it. This is not an array. It then calls the ToArray extension on that IEnumerable instance. We now have an Integer array. ","Integer ","integer-vbnet","Tip: ","ToArray is found within System.Linq. It can be called on any type instance that implements IEnumerable.","Tip 2: ","Many types implement IEnumerable. And we can even use The IEnumerable type itself\u2014this is what we do in this program.","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","VB.NET program that uses ToArray","\n\nModule Module1\n Sub Main()","\n ' Create an IEnumerable range.\n ' This is not an array.\n ","Dim e As IEnumerable(Of Integer) = Enumerable.Range(0, 10)","\n\n ' Use ToArray extension to convert to an array.\n ","Dim array() As Integer = e.","ToArray","()","\n\n ' Display elements.\n ","For Each i As Integer In array\n Console.WriteLine(i)\n Next\n End Sub\nEnd Module\n\n","Output","\n\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9","Internals."," I investigated the ToArray extension Function. It is located within System.Core.dll in the .NET Framework's folder. I opened this file with IL Disassembler and then navigated to System.Linq.ToArray. ","IL Disassembler ","il-disassembler","Eventually,"," this Function allocates a new array. It then calls into Array.Copy. This newly-allocated array is returned to the calling Function. So there is no performance benefit to calling ToArray. It mainly improves the syntax. ","Tip: ","Some collections, such as List, offer a separate ToArray Function. This is not an extension method.","List ","list-vbnet","Summary."," We explored the ToArray extension Function from System.Linq. We used it with an IEnumerable instance and the Enumerable.Range Function. And we investigated its internals, which allocate a new array and call Array.Copy. ","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","3679700504","data-ad-format","link","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto"],"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANYAAAA3CAMAAABHJUQ7AAAAMFBMVEX////7/f7y/f+38v//6en/1dX/tbX/xcXl+v/U9//G9f//qKiq8P+U7P+e7v//lJQSDb6dAAAEaklEQVR4Xt2Z27KiMBBF050bN/X//3aQiBvZoeMZHoYz+8myKYtFeuWCDomfcY30n3EXTXh8xtnp7p+5KlbcYYXGYE1rCpZeFCvtsBpdOPiSFe6qXfjYJTWwlgBt+AVqteXSfgnQ/MXVSl/Jpd2Svu/6oUQvrVZ24zdy6RrXlUHrr4mFMcosV2Pc+jnXxArAioZcRj/qldUaPwjtSEzPi0RnMFWpFrcJIea0qpvyZ1GEfn77laieU8tZcm2IQ17ZRVXFKurzi1VZZAzLWEu56G13XN0VPO3ktNvZ628lvUP6W4mHWkBhuRgrJDA4ETGLQusHCERFSgvDafwknvaMNXRbrAEIhDqwWo7lYiw8+tAsLsyMheF8Um3Jq90hM5ZXh3QvhLtDbq90rJYpV+3G7KKNlYo2i5nCToO0YA0OkZVBifRWUYvkOoFFHVoFL/bBbzgNtQrWpIZctlok11ksfWGllOKcMCfDrtdw7SBKALpiddX5gUFZLVMuaqK43LlRLB22T6xgQS5Wa8XqDbkMtYjSwsrhxaNyUFzXNEcZ0fUL+o6C1HK6YEGuDYU21aKeJCwwoaAq9aKUHQgNF83m1HN0UcHy1so12GoBMx1hZdnte7mI/WLXMRY8qn9JU9dCBayaXJOhli1XvTu103pxhlqwXBurIpeQWndgcdM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