با عرض سلام و خسته نباشید خدمت کاربران وب سایت پروگرم 98 😉 در این مطلب از وب سایت پروگرم 98 کد افزودن مقدار به Generic List و نمایش مقادیر با array indexing در سی شارپ را آماده کردم. انشاالله که این کد براتون مفید باشه.
خروجی کد به این صورت می باشد :
Initial number of elements: 0
Adding 6 elements
Number of elements: 6
Current contents: C A E B D F
Adding 6 elements
Number of elements: 6
Current contents: C A E B D F
کد افزودن مقدار به Generic List و نمایش مقادیر با array indexing در سی شارپ :
using System;
using System.Collections.Generic;
class MainClass {
public static void Main() {
List<char> lst = new List<char>();
Console.WriteLine("Initial number of elements: " +
lst.Count);
Console.WriteLine();
Console.WriteLine("Adding 6 elements");
lst.Add('C');
lst.Add('A');
lst.Add('E');
using System.Collections.Generic;
class MainClass {
public static void Main() {
List<char> lst = new List<char>();
Console.WriteLine("Initial number of elements: " +
lst.Count);
Console.WriteLine();
Console.WriteLine("Adding 6 elements");
lst.Add('C');
lst.Add('A');
lst.Add('E');