ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Create new List with for loop in C# and VB.Net<p>I am checking it, I will get back to you soon.</p>https://www.aspforums.net:443/Threads/331907/Create-new-List-with-for-loop-in-C-and-VBNet/https://www.aspforums.net:443/Threads/331907/Create-new-List-with-for-loop-in-C-and-VBNet/Thu, 09 Aug 2018 23:56:58 GMTCreate new List with for loop in C# and VB.Net<p>Hi <a class="username" rel="Jayakumar">Jayakumar</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { List&lt;List&lt;int&gt;&gt; lists = new List&lt;List&lt;int&gt;&gt;(); List&lt;int&gt; list = new List&lt;int&gt;(); for (int i = 1; i &lt;= 2742; i++) { list.Add(i); if (i % 100 == 0) { lists.Add(list); list = new List&lt;int&gt;(); } } lists.Add(list); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim lists As List(Of List(Of Integer)) = New List(Of List(Of Integer))() Dim list As List(Of Integer) = New List(Of Integer)() For i As Integer = 1 To 2742 list.Add(i) If i Mod 100 = 0 Then lists.Add(list) list = New List(Of Integer)() End If Next lists.Add(list) End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/331907/Create-new-List-with-for-loop-in-C-and-VBNet/https://www.aspforums.net:443/Threads/331907/Create-new-List-with-for-loop-in-C-and-VBNet/Fri, 10 Aug 2018 03:17:24 GMT