當前位置: 首頁>>代碼示例>>C#>>正文


C# ArrayList.set方法代碼示例

本文整理匯總了C#中java.util.ArrayList.set方法的典型用法代碼示例。如果您正苦於以下問題:C# ArrayList.set方法的具體用法?C# ArrayList.set怎麽用?C# ArrayList.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.ArrayList的用法示例。


在下文中一共展示了ArrayList.set方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: testFormatByPattern

        public void testFormatByPattern()
        {
            NumberFormat newNumFormat = new NumberFormat();
            newNumFormat.setPattern("(\\d{3})(\\d{3})(\\d{4})");
            newNumFormat.setFormat("($1) $2-$3");
            List<NumberFormat> newNumberFormats = new ArrayList<NumberFormat>();
            newNumberFormats.add(newNumFormat);

            assertEquals("(650) 253-0000", phoneUtil.formatByPattern(US_NUMBER, PhoneNumberFormat.NATIONAL,
                                                             newNumberFormats));
            assertEquals("+1 (650) 253-0000", phoneUtil.formatByPattern(US_NUMBER,
                                                                PhoneNumberFormat.INTERNATIONAL,
                                                                newNumberFormats));
            assertEquals("tel:+1-650-253-0000", phoneUtil.formatByPattern(US_NUMBER,
                                                                  PhoneNumberFormat.RFC3966,
                                                                  newNumberFormats));

            // $NP is set to '1' for the US. Here we check that for other NANPA countries the US rules are
            // followed.
            newNumFormat.setNationalPrefixFormattingRule("$NP ($FG)");
            newNumFormat.setFormat("$1 $2-$3");
            assertEquals("1 (242) 365-1234",
                 phoneUtil.formatByPattern(BS_NUMBER, PhoneNumberFormat.NATIONAL,
                                           newNumberFormats));
            assertEquals("+1 242 365-1234",
                 phoneUtil.formatByPattern(BS_NUMBER, PhoneNumberFormat.INTERNATIONAL,
                                           newNumberFormats));

            newNumFormat.setPattern("(\\d{2})(\\d{5})(\\d{3})");
            newNumFormat.setFormat("$1-$2 $3");
            newNumberFormats.set(0, newNumFormat);

            assertEquals("02-36618 300",
                 phoneUtil.formatByPattern(IT_NUMBER, PhoneNumberFormat.NATIONAL,
                                           newNumberFormats));
            assertEquals("+39 02-36618 300",
                 phoneUtil.formatByPattern(IT_NUMBER, PhoneNumberFormat.INTERNATIONAL,
                                           newNumberFormats));

            newNumFormat.setNationalPrefixFormattingRule("$NP$FG");
            newNumFormat.setPattern("(\\d{2})(\\d{4})(\\d{4})");
            newNumFormat.setFormat("$1 $2 $3");
            newNumberFormats.set(0, newNumFormat);
            assertEquals("020 7031 3000",
                 phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL,
                                           newNumberFormats));

            newNumFormat.setNationalPrefixFormattingRule("($NP$FG)");
            assertEquals("(020) 7031 3000",
                 phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL,
                                           newNumberFormats));

            newNumFormat.setNationalPrefixFormattingRule("");
            assertEquals("20 7031 3000",
                 phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL,
                                           newNumberFormats));

            assertEquals("+44 20 7031 3000",
                 phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.INTERNATIONAL,
                                           newNumberFormats));
        }
開發者ID:jason-persson,項目名稱:LibPhoneNumberPortable,代碼行數:61,代碼來源:PhoneNumberUtilTest.cs

示例2: RegionFile

        public RegionFile(File file)
        {
            lastModified = 0L;
            fileName = file;
            debugln((new StringBuilder()).append("REGION LOAD ").append(fileName).toString());
            sizeDelta = 0;
            try
            {
                if (file.exists())
                {
                    lastModified = file.lastModified();
                }
                dataFile = new RandomAccessFile(file, "rw");
                if (dataFile.length() < 4096L)
                {
                    for (int i = 0; i < 1024; i++)
                    {
                        dataFile.writeInt(0);
                    }

                    for (int j = 0; j < 1024; j++)
                    {
                        dataFile.writeInt(0);
                    }

                    sizeDelta += 8192;
                }
                if ((dataFile.length() & 4095L) != 0L)
                {
                    for (int k = 0; k < (dataFile.length() & 4095L); k++)
                    {
                        dataFile.write(0);
                    }
                }
                int l = (int) dataFile.length()/4096;
                sectorFree = new ArrayList(l);
                for (int i1 = 0; i1 < l; i1++)
                {
                    sectorFree.add(Boolean.valueOf(true));
                }

                sectorFree.set(0, Boolean.valueOf(false));
                sectorFree.set(1, Boolean.valueOf(false));
                dataFile.seek(0L);
                for (int j1 = 0; j1 < 1024; j1++)
                {
                    int l1 = dataFile.readInt();
                    offsets[j1] = l1;
                    if (l1 == 0 || (l1 >> 8) + (l1 & 0xff) > sectorFree.size())
                    {
                        continue;
                    }
                    for (int j2 = 0; j2 < (l1 & 0xff); j2++)
                    {
                        sectorFree.set((l1 >> 8) + j2, Boolean.valueOf(false));
                    }
                }

                for (int k1 = 0; k1 < 1024; k1++)
                {
                    int i2 = dataFile.readInt();
                    chunkTimestamps[k1] = i2;
                }
            }
            catch (IOException ioexception)
            {
                ioexception.printStackTrace();
            }
        }
開發者ID:riverar,項目名稱:Crafty,代碼行數:69,代碼來源:RegionFile.cs


注:本文中的java.util.ArrayList.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。