Microsoft MVP성태의 닷넷 이야기
List<ArrarySegment<int>> 사용법 질문드립니다! [링크 복사], [링크+제목 복사],
조회: 13852
글쓴 사람
한예지 donator
홈페이지
첨부 파일
 

선생님 안녕하세요!
using System;
using System.Collections.Generic;
public class Hello1
{
    public static void Main()
    {
        int[] array = { 10, 20, 30, 40, 50, 60, 70, 80, 90 };
        
        List<ArraySegment<int>> list = new List<ArraySegment<int>>();
        
    ArraySegment<int> segment1 = new ArraySegment<int>(array, 0, 2); // 10, 20
        ArraySegment<int> segment2 = new ArraySegment<int>(array, 4, 3); // 50, 60, 70
        
        list.Add(segment1);
        list.Add(segment2);

        for(int i = 0; i < list.Count; i++)
            Console.WriteLine(list[i]);
     }
}


[출력]
System.ArraySegment`1[System.Int32]
System.ArraySegment`1[System.Int32]

[질문 1]
저는 Array에 있는 것을 일부 떼어서 ArraySegment에 각각 옮긴 후,
이것을 list에 추가하려고 합니다.
예상 출력값을 10, 20, 50, 60, 70으로 생각했지만
알 수 없는 출력값이 보입니다...
어떻게 하면 되는지 도움 부탁드립니다!








[최초 등록일: ]
[최종 수정일: 12/23/2020]


비밀번호

댓글 작성자
 



2020-12-23 11시59분
간단하게 생각해서, 다음의 값이 "1, 2, 3"으로 나오진 않습니다.

ArraySegment<int> elems = new ArraySegment<int>(new [] { 1, 2, 3 });
Console.WriteLine(elems);

결국 지난번 했던 질문과 동일한 유형입니다.

제네릭 리스트 출력하는 방법이 궁금합니다.
; https://www.sysnet.pe.kr/3/0/5414
정성태
2022-03-05 02시30분
[bbb] class Program
    {
        static void Main(string[] args)
        {
                int[] array = { 10, 20, 30, 40, 50, 60, 70, 80, 90 };

                List<ArraySegment<int>> list = new List<ArraySegment<int>>();

                ArraySegment<int> segment1 = new ArraySegment<int>(array, 0, 2); // 10, 20
                ArraySegment<int> segment2 = new ArraySegment<int>(array, 4, 3); // 50, 60, 70

                list.Add(segment1);
                list.Add(segment2);

            for (int i = 0; i < list.Count; i++)
            {
                for(int j = 0; j < list[i].Count; j++)
                Console.WriteLine(list[i].Array[list[i].Offset+j]);
            }
        }
    }
[guest]

... 46  47  48  49  50  51  52  53  [54]  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
1336이소정10/27/201416623filestream seek에 대해 질문있습니다. [1]
1337이소정10/28/201416936    답변글 [답변]: filestream seek에 대해 질문있습니다.파일 다운로드1
1339이소정10/28/201419880        답변글 [답변]: [답변]: filestream seek에 대해 질문있습니다. [2]파일 다운로드2
1335황지혜10/24/201420645psexec 관련 질문드립니다. [1]
1334dell10/24/201416653여기가 있는줄 모르고 방명록에 남겼네요 ㅠㅠ 방명록 한번만 봐주시면 안될지요? [1]
1333왕초보10/24/201417051Bitmap 질문 [5]
1332김동진10/16/201423773clickonce 와 smartscreen filter 기능에 대해서 [2]
1331궁굼합니다10/8/201417250loopback adapter 자동 설치가 가능 한가요? [2]
1330이현중10/8/201419870파일 다운로드 방법 문의 [2]파일 다운로드1
1329popo10/2/201417258싱글톤과 싱글톤 소멸자에 대해 궁금점이 있습니다. [1]
1328달쏭9/25/201418313WCF Service측에서 parameter 값이 null이 오는 이유를 알고 싶어요. [2]
1326궁굼합니다9/19/201417486VB의 Shell 기능과 완벽히 똑같은 기능의 함수 [4]
1325지현태9/18/201417237WPF 의존속성과 바인딩에 대한 질문입니다.. [1]파일 다운로드1
1324popo9/17/201416410wcf 질문 드립니다. [1]
1323Anon...9/17/201418777인스턴스와 객체의 차이 [1]
1322김영대9/16/201418704죄송하지만 .NET 관련 질문게시판이지만 혹시 ASP.NET MVC에 대해서 질문 드려도 됩니까 (__);; [2]
1321부탁드립...9/15/201420610윈도우 어플리케이션 개발 방법(?) 에대해(직접적인 코드라기보단 프로젝트 방향??) [14]
1320소켓서버...9/13/201421021서로다른 포트번호로 로컬 Socket 서버를 개설시 Close 문제 입니다. [2]
1319ㅇㅇ9/12/201421769134쪽 예제 오타 [3]
1318블루투쓰9/12/201417333page 184 질문드립니다. [1]
1316서동원8/21/201423404ActiveX 개체가 이 속성 또는 메서드를 지원하지 않습니다. [1]
1313양해진8/20/201415773메시지창에 대해서요 [1]
1312김영대8/18/201418015안녕하십니까 정성태님 죄송하지만 C#.NET의 FileInfo 클래스의 CopyTo 메서드 질문드립니다. [3]
1311김솔8/18/201418796nsis파일 수정중에요! [2]
1310조정용8/17/201420055WCF 프로그램에서 Task를 이용한 백그라운드 작업 시 클라이언트에 대한 병목현상. [4]파일 다운로드1
1309서동원8/12/201418117안녕하세요. embeded dll과 관련하여 질문드립니다. [4]
... 46  47  48  49  50  51  52  53  [54]  55  56  57  58  59  60  ...