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

... 61  62  63  64  [65]  66  67  68  69  70  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
981김창욱7/11/201121143주식형태의 프로그램 처럼 SQL서버의 특정 필드 데이터의 변화가 있을때 재 클라이언트가 정보를 갱신 할 수 있게 하는 방법은 없을까요? [2]
980YJ7/7/201120870App Pool idle time 과 WCF 서비스의 비동기 function 호출. [3]
979왕초보7/1/201119190Apache + IIS Redirect [2]
9776/16/201123078웹컨트롤 어느거 쓰는게 좋나요 [1]
976박성준6/13/201118567VS2008 Add-in 구현 관련 질문 [4]
972김길6/6/201120844메모리 해제 예외 처리 관련.. [2]
971강동원5/29/201118440firebird install건 [1]
970임동찬5/18/201119188ASP.net 솔루션 디버깅 관련 [1]
969이성환5/4/201120817WMI 를 사용하지 않고 하드웨어 정보를 가져올 수 없을까요? [3]
968김동미4/28/201120264안녕하세요 다시 한번 문의를 드립니다.. [2]파일 다운로드1
967임동찬4/22/201122936C# using문 관련 [9]
964김동미4/18/201120582wcf IsOneWay 속성관련 문의 입니다..
965정성태4/18/201121900    답변글 [답변]: wcf IsOneWay 속성관련 문의 입니다..
966김동미4/19/201119548        답변글 [답변]: [답변]: wcf IsOneWay 속성관련 문의 입니다.. [1]
963최재훈4/12/201118164wcf inactivityTimeout 설정시 문의 사항이 있습니다. [2]
962임동찬4/8/201117840TFS 사용관련 [1]
961임동찬4/7/201118098XSD & XML & XmlCodeGenerator [2]
960임동찬4/5/201119764XML Schema Editor [4]
959immm3/24/201117543로그인 연동 어려운 건가요? [1]
958꼭지3/3/201119696Supporting compressed request in WCF 3.5 [5]
957임동찬2/21/201120119WCF channel faulted 관련 [2]
956윤용한2/18/201123548WaitHandle.WaitOne 과 Stopwatch에 관한 질문 [3]
955최광욱2/17/201120225TFS 에서 소스 영구 제거 방법 [1]
954한장우2/16/201117890atl activeX 질문이요~ [1]
952박용운2/16/201118757IE8.0에서 BHO [1]
953박용운2/16/201118721    답변글 [답변]: IE8.0에서 BHO
... 61  62  63  64  [65]  66  67  68  69  70  71  72  73  74  75  ...