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 List object from another List using C# and VB.Net in WPF Application<p>Hey <a class="username" rel="bigbear"> bigbear</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">private List&lt;Product&gt; listOfP = new List&lt;Product&gt;(); public List&lt;Product&gt; Cart = new List&lt;Product&gt;(); public Form1() { InitializeComponent(); List&lt;Product&gt; listprod = new List&lt;Product&gt;(); listprod.Add(new Product { ProductName = &#34;p1&#34;, ProductPrice = 50, ProductQuantity = 10, ProductSalesTax = 5 }); listprod.Add(new Product { ProductName = &#34;p2&#34;, ProductPrice = 70, ProductQuantity = 15, ProductSalesTax = 8 }); listOfP = listprod; ShoppingCart(listOfP); } public void ShoppingCart(List&lt;Product&gt; listprod) { CreateCart(listprod); } private void CreateCart(List&lt;Product&gt; lcart) { foreach (Product product in lcart) { Cart.Add(product); } } public class Product { public string ProductName { get; set; } public decimal ProductPrice { get; set; } public decimal ProductSalesTax { get; set; } public int ProductQuantity { get; set; } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Private listOfP As List(Of Product) = New List(Of Product)() Public Cart As List(Of Product) = New List(Of Product)() Public Sub New() InitializeComponent() Dim listprod As List(Of Product) = New List(Of Product)() listprod.Add(New Product With { .ProductName = &#34;p1&#34;, .ProductPrice = 50, .ProductQuantity = 10, .ProductSalesTax = 5 }) listprod.Add(New Product With { .ProductName = &#34;p2&#34;, .ProductPrice = 70, .ProductQuantity = 15, .ProductSalesTax = 8 }) listOfP = listprod ShoppingCart(listOfP) End Sub Public Sub ShoppingCart(ByVal listprod As List(Of Product)) CreateCart(listprod) End Sub Private Sub CreateCart(ByVal lcart As List(Of Product)) For Each product As Product In lcart Cart.Add(product) Next End Sub Public Class Product Public Property ProductName As String Public Property ProductPrice As Decimal Public Property ProductSalesTax As Decimal Public Property ProductQuantity As Integer End Class</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/jZISL6r.jpg" alt="" width="448" height="384" /></p>https://www.aspforums.net:443/Threads/649531/Create-List-object-from-another-List-using-C-and-VBNet-in-WPF-Application/https://www.aspforums.net:443/Threads/649531/Create-List-object-from-another-List-using-C-and-VBNet-in-WPF-Application/Thu, 06 Dec 2018 00:34:08 GMT