Microsoft MVP성태의 닷넷 이야기
List<ArrarySegment<int>> 사용법 질문드립니다! [링크 복사], [링크+제목 복사],
조회: 13897
글쓴 사람
한예지 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)
27411/25/200510269        답변글 답변 감사드립니다.
265하수11/14/2005101852개의 dll연결 해야 하는구문은 [1]
263하수11/11/200510251Smart Client(DB 연동에 질문영) [1]
260상수11/10/200511150Object등록시 에러 (Smart Client)
261정성태11/10/200510907    답변글 [답변]: Object등록시 에러 (Smart Client)
259바보스런...11/9/200510559스마트 질문좀 할께요. 죄송합니다.파일 다운로드1
262정성태11/10/200510351    답변글 [답변]: 스마트 질문좀 할께요. 죄송합니다. [1]
264Yuri11/11/20059932        답변글 [답변]: [답변]: 스마트 질문좀 할께요. 죄송합니다. [1]
266유리11/15/200510807            답변글 [답변]: [답변]: [답변]: 스마트 질문좀 할께요. 죄송합니다. [2]
257차우차우10/28/200510357스마트 클라이언드 에서.. 수정하면 안돼는 문제? [1]파일 다운로드1
254박상호10/26/200510457스마트 클라이언트관련해서 질문이 있습니다. [1]
253Lee ...10/27/200510394안녕하세요. 바쁘신데 이렇게 질문드려서 죄송합니다. 스마트 클라이언트에 관한 질문입니다. [2]
252홍영진10/26/200510744SmartClient 배포시 닷넷프레임워크배포
255정성태10/27/200511074    답변글 [답변]: SmartClient 배포시 닷넷프레임워크배포
249ROY10/23/200510455X-internet & Peer to Peer
251정성태10/24/200511027    답변글 [답변]: X-internet & Peer to Peer [1]
246뽀송이10/17/200510827스마트클라이언트 개념에 대한 질문입니다.(Connection Pool사용 가능?) [2]
247정성태10/17/200510877    답변글 [답변]: 스마트클라이언트 개념에 대한 질문입니다.(Connection Pool사용 가능?)
248뽀송이10/17/200511164        답변글 [답변]: [답변]: 스마트클라이언트 개념에 대한 질문입니다.(DB연동을 웹서비스로 하면 문제는?) [3]
245오혁천10/12/200511598스마트 클라이언트에서.. Socket 함수 사용 [1]
244정우기10/11/200510796스마트클라이언드 권한관련 콜솔 프로그램 에 관하여 문의좀..ㅜ.,ㅜ [1]
242이용희10/7/200510896스마트클라이언트 배포시 .NET Framework 버전에 관한 문제
243정성태10/10/200510742    답변글 [답변]: 스마트클라이언트 배포 시 .NET Framework 버전에 관한 문제 [3]
241김재옥10/5/200510603smart client에서의 Socket 함수 사용 [1]
240이형배9/15/200510071스마트클라이언트배우고 싶어여... [1]
239장강현9/14/200514948SmartClient에서의 배포 문제에 대해 [2]
... 76  77  78  79  80  81  82  83  84  85  86  87  [88]  89  90  ...