locked
Tables.Row(0).Count - 1 RRS feed

  • Pertanyaan

  • Apa fungsi dari Tables.Row(0).Count - 1 ?

    Suhendi

    Rabu, 06 Januari 2016 02.07

Jawaban

  • Hi Suhendi,

    Tables.Row(0).Count

    artinya menghitung jumlah baris pertama dalam sebuah tabel,


    Agile and ALM blog at http://ridilabs.net :)

    Kamis, 07 Januari 2016 00.10

Semua Balasan

  • Hi Suhendi,

    Tables.Row(0).Count

    artinya menghitung jumlah baris pertama dalam sebuah tabel,


    Agile and ALM blog at http://ridilabs.net :)

    Kamis, 07 Januari 2016 00.10
  • Hai...apa kabar Suhendi.

    Kalau saya boleh tahu objek Tables yang kamu gunakan tipe datanya apa ...? kalau tipe datanya adalah DataTable maka fungsi dari properti Count adalah "memberikan nilai total jumlah dari objek System.Data.DataRow yang terdapat pada objek DataTable. Objek (atau kelas jika belum di instansiasi) DataTable memiliki properti Rows (bukan Row) yang dapat di gunakan untuk mengakses semua kumpulan atau koleksi objek System.Data.DataRow. Perhatikan bahwa property Rows memiliki tipe DataRowCollection dimana DataRowCollection ini mewarisi (meng-inherit) kelas InternalDataCollectionBase. Jika anda periksa kode sumber untuk kelas InternalDataCollectionBase, anda akan menemukan bahwa kelas ini mengimplementasikan dua interface yaitu ICollection dan IEnumerable. Seperti yang kita ketahui, berikut adalah kode sumber untuk interface ICollection.

    #region Assembly mscorlib.dll, v4.0.0.0
    // C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll
    #endregion
    
    using System;
    using System.Runtime.InteropServices;
    
    namespace System.Collections
    {
        // Summary:
        //     Defines size, enumerators, and synchronization methods for all nongeneric
        //     collections.
        [ComVisible(true)]
        public interface ICollection : IEnumerable
        {
            // Summary:
            //     Gets the number of elements contained in the System.Collections.ICollection.
            //
            // Returns:
            //     The number of elements contained in the System.Collections.ICollection.
            int Count { get; }
            //
            // Summary:
            //     Gets a value indicating whether access to the System.Collections.ICollection
            //     is synchronized (thread safe).
            //
            // Returns:
            //     true if access to the System.Collections.ICollection is synchronized (thread
            //     safe); otherwise, false.
            bool IsSynchronized { get; }
            //
            // Summary:
            //     Gets an object that can be used to synchronize access to the System.Collections.ICollection.
            //
            // Returns:
            //     An object that can be used to synchronize access to the System.Collections.ICollection.
            object SyncRoot { get; }
    
            // Summary:
            //     Copies the elements of the System.Collections.ICollection to an System.Array,
            //     starting at a particular System.Array index.
            //
            // Parameters:
            //   array:
            //     The one-dimensional System.Array that is the destination of the elements
            //     copied from System.Collections.ICollection. The System.Array must have zero-based
            //     indexing.
            //
            //   index:
            //     The zero-based index in array at which copying begins.
            //
            // Exceptions:
            //   System.ArgumentNullException:
            //     array is null.
            //
            //   System.ArgumentOutOfRangeException:
            //     index is less than zero.
            //
            //   System.ArgumentException:
            //     array is multidimensional.-or- The number of elements in the source System.Collections.ICollection
            //     is greater than the available space from index to the end of the destination
            //     array.-or-The type of the source System.Collections.ICollection cannot be
            //     cast automatically to the type of the destination array.
            void CopyTo(Array array, int index);
        }
    }
    

    Perhatikan properti Count pada kode di atas. Properti ini harus di implementasikan oleh kelas yang menggunakan interface ICollection. Dengan demikian, Count adalah properti untuk memberikan jumlah element dalam hal ini jumlah System.Data.DataRow objek. Jadi jika jumlah System.Data.DataRow objek adalah 5 maka properti ini akan memberikan hasil 5.

    Minggu, 10 Januari 2016 14.48