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

... 76  [77]  78  79  80  81  82  83  84  85  86  87  88  89  90  ...
NoWriterDateCnt.TitleFile(s)
594ygso...3/13/200714277ClickOnce를 이용하여 SmartClient를 배포할경우.. [2]
589김희택3/2/200713431리소스 추가 방법에 대한 아티클을 보던중에 질문요... [1]파일 다운로드1
588이성진2/24/200715691웹 -> 스마트클라이언트 -> 웹서비스 의 세션 공유 방법 ? [1]
583김영민2/22/200713884Vista에서 "관리자 권한으로 실행"을 통해 실행한 프로세스의 동작
584정성태2/22/200715373    답변글 [답변]: Vista에서 "관리자 권한으로 실행"을 통해 실행한 프로세스의 동작
582한귀순2/22/200713941sqlhelper 의 updatedataset
585정성태2/23/200713164    답변글 [답변]: sqlhelper 의 updatedataset [1]
579futu...2/16/200714665VS2005의 스마트 클라이언트에서 웹브라우저 예제 질문입니다. [1]
578정해봉2/16/200713890IE Embeded Assambly 방식에서 CAS 설정 방법 [1]
575박성민2/12/200714686COM에 데이터 보내기 질문입니다. [1]
571엔틱스2/7/200715386그냥... 질문은 아닙니다만... [2]
5682/6/200712616이런 오류 화면을 어떻게 찾아봐야 - 알아봐야 - 하는지요?파일 다운로드1
569정성태2/6/200714125    답변글 [답변]: 이런 오류 화면을 어떻게 찾아봐야 - 알아봐야 - 하는지요? [1]
570정성태2/6/200714018        답변글 [답변]: [답변]: 이런 오류 화면을 어떻게 찾아봐야 - 알아봐야 - 하는지요?
5732/8/200713020            답변글 [답변]: [답변]: [답변]: 이런 오류 화면을 어떻게 찾아봐야 - 알아봐야 - 하는지요? [1]파일 다운로드1
565한귀순2/5/200713578typed dataset 의 유용성
566정성태2/6/200715413    답변글 [답변]: typed dataset의 유용성 [1]
564정민영2/5/200713837혹시 이런 경우 보신적 있으신가 궁금합니다..^^; [2]
563창민이2/2/200713973Visual C++ COM Objects Returning Recordsets 사용에 대해.. [3]
562현석1/29/200713990C# 스마트응용장치에서 아이콘 움직이게하는거 질문요 ^^ [1]파일 다운로드1
559초보1/27/200715288급 질문 입니다. visual studio 자동 종료에 대한 질문입니다. [2]
558즈믄1/26/200714980.Net Framework v2.0에서 Winform의 Panel에 Excel파일 보여주기 [2]
556정재우1/26/200715062vista에서 smartclient의 System.Security.PermissionsRegistryPermission 에러 [1]
555dev....1/25/2007164492005 WebBrowser내에서 팝업 처리 문제 관련 질문입니다.
561정성태1/29/200719329    답변글 [답변]: 2005 WebBrowser 내에서 팝업 처리 문제 관련 질문입니다.
554sky1/23/200715120<급질문> interop 를 사용함에 있어 [2]
... 76  [77]  78  79  80  81  82  83  84  85  86  87  88  89  90  ...