Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

example of List c#


			List<string> listOfString = new List<string>();
			listOfString.Add("georgel");
			listOfString.Add("marcel");
			for (int i = 0; i < listOfString.Count; i++)
			{
				Console.WriteLine("the strings are: " + listOfString[i]);
			}

			List<User> listOfUser = new List<User>()
			{
                new User() { Name = "john", Age = 22 },
				new User() { Name = "john", Age = 44 },

			};

			for (int i = 0; i < listOfUser.Count; i++)
            {
				Console.WriteLine("the name is: " + listOfUser[i].Name + " and the age is: " + listOfUser[i].Age);
            }
            
            //USER CLASS
           class User
    		{
       		 public string Name { get; set; }
       		 public int Age { get; set; }
   			 }
 
PREVIOUS NEXT
Tagged: #List
ADD COMMENT
Topic
Name
4+3 =