سلام بر تمامی برنامه نویسان #C 😉 در این پست کد ویرایش و تغییر آیتم های Generic List با array indexing در سی شارپ را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
خروجی این کد به این صورت است:
Initial number of elements: 0
Adding 6 elements
Number of elements: 6
Change first three elements
Contents: X Y Z B D F
Adding 6 elements
Number of elements: 6
Change first three elements
Contents: X Y Z 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');
lst.Add('B');
lst.Add('D');
lst.Add('F');
Console.WriteLine("Number of elements: " +
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');
lst.Add('B');
lst.Add('D');
lst.Add('F');
Console.WriteLine("Number of elements: " +