Microsoft MVP성태의 닷넷 이야기
List<ArrarySegment<int>> 사용법 질문드립니다! [링크 복사], [링크+제목 복사],
조회: 6349
글쓴 사람
한예지 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]

... 16  17  18  19  20  21  22  23  24  25  26  27  [28]  29  30  ...
NoWriterDateCnt.TitleFile(s)
51837/2/20197866.NET Compact Freamwork 컨트롤러 더블버퍼링 [1]
5182wpf ...7/2/20198050wpf 질문 드립니다. [1]파일 다운로드1
51817/1/20198490DataGridview Doublebuffer 에 대해서 질문드립니다. [2]
5180김대훈6/25/20198504배열과 반복문에서 질문드립니다 [2]
5177농상6/13/20199665멀티스레드 건의 [2]
5176이선호6/13/20199246안녕하세요. 닷넷 문제로 검색하다 알게되어 들어왔습니다. 현재 IIS 문제가 있어 질문드립니다. [1]
5175Chobo6/12/20199220WPF Ellipse 그리기! [3]
5174농상6/11/20198554ThreadPool 조인에 관해 [1]
5173전우치6/9/20198995공유 리소스에 대한 스레드 동기화 처리를 위해서 lock 이용 시 문의 [3]
5172김대훈6/7/20197806너무힘드네요 공부에 대한조언부탁드립니다 [2]
5171조남석6/4/20197501EX)11-2(treeview)에 대한 질문입니다. [3]
5170레리6/4/20198119Setup 프로젝트 레지스트리 설정 관련 질문입니다. [1]파일 다운로드1
5169농상6/3/20197884멀티스레드 파라미터 관련 [2]
5168익명유저5/30/20197182항상 정말 감사드립니다... [1]
5167WPF5/23/20198074질문드립니다. [1]
5165이대희5/22/20197233Visual Studio 설치 구성요소 문의 (C# 7.3 개정판 관련) [1]
5164레드5/21/20198750실행 과정과 실행파일 디버그 시 Icon변경 질문드립니다. [5]
5163이대희5/20/20197051시작하세요 C# 7.3 프로그래밍 책 도착했습니다. [1]
5162채홍윤5/14/20199865Mono Develop window 설치 [6]
5161정대영5/13/20197809VS 2013에서 C#6.0(.netFramwork 4.6.1) $ 디버깅 오류 [1]
5160초보개발자5/13/20198790wcf 관련 국내 서적 살만한 책이 있나요? [2]
5159sdh25/9/20198328VS 2010 버전에서 생성한 DLL을 VS 2017버전에서 실행 시 에러 [2]
5158sdh5/8/20197227Visual studio 2010 버전에서 생성한 Project를 Visual studio 2017버전에서 실행에러 [1]
5157김경훈5/8/201910214Task 만들때 넘겨주는 CancellationToken은 어디서 사용 되는 건가요? [4]
5156rysoo5/8/20198475yield return의 리턴 타입 질문 드립니다. [4]
5155세퉁5/7/201910395관리자 권한으로 실행 시 알림창(?) 없이 바로 실행 시킬 수 있는 방법이 있을까요?? [2]파일 다운로드1
... 16  17  18  19  20  21  22  23  24  25  26  27  [28]  29  30  ...