• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Collection Initialize ASP.net

What is Collection Initialize

Collection Initialize are used to initialize multiple object values at once.

In general collection initialize   are created by using “List” collection class and list collection class is initialized from  “ I enumerable”   Interface.

Example  with collection Initializes :-

Name space  CA Sample
{
Class Employee 2
{
Public int age, Emp Id;
Public String ename, address;
}
Class Example 6
{
Static void Main ()
{
List <Employee 2> Emp list  = New list  < Employee 2>  ()
{
New Employee 2 {  emp id = 101 , e name = “R” Add. “hyd”, “Age = 22”}
New Employee 2 {  emp id = 102 , e name = “V” Add. “bglr”, “Age = 24”}
};
For each (var x in emplist)
C.W.L (“X.emp id +”,”+x.ename +”,”+x.add+ “,”+x.age);
  Read ();
}
}
}

Working with Query’s in LINQ :-

A LINQ Query that is divided in to 3 types :-

  1. From Clause
  2. Where Clause
  3. Select Clause
Interested in mastering ASP.net Training?Enroll now for FREE demo on ASP.net Training.

Syntax of Query in LINQ :-

Syn :-  From Variable in  collection Name Where condition Select variable .

Select variable   (select clause)

  • When we want with Query in LINQ we need to follow 3 steps
  1. preparing Data Stage.

2.Writing Query.

3.Executing Query.

 

 Example to work with query on Simple list data :-

Name space  CA Sample
{
Class Employee 7
{
Static void Main ()
Step 1 // List <int>  L1 = new list <int>  {1,2,3,4,5,6,7,8,9,10};
Var  R = From  X in L1 where XYZ == 0 Select X;  //step 2
C.W.L   (“Even No in The list are :-”);
For each  (var I in R); //step 3
   Write (I + “”);
   Read ();
}
}
}

For indepth understanding click on

Summary
Review Date
Reviewed Item
Collection Initialize ASP.net
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Collection Initialize ASP.net"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.