C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet210/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   206   207   208   209   210   211   212   213   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

nums1

 to 


nums2

, both array reference 

variables refer to the same object.

www.freepdf-books.com




148

 

P a r t   I :  



T h e   C #   L a n g u a g e

Using the Length Property

A number of benefits result because C# implements arrays as objects. One comes from the 

fact that each array has associated with it a 

Length

 property that contains the number of 

elements that an array can hold. Thus, each array provides a means by which its length can 

be determined. Here is a program that demonstrates this property:

// Use the Length array property.

using System;

class LengthDemo {

  static void Main() {

    int[] nums = new int[10];

    Console.WriteLine("Length of nums is " + nums.Length);

    // Use Length to initialize nums.

    for(int i=0; i < nums.Length; i++)

      nums[i] = i * i;

    // Now use Length to display nums.

    Console.Write("Here is nums: ");

    for(int i=0; i < nums.Length; i++)

      Console.Write(nums[i] + " ");

    Console.WriteLine();

  }

}

This program displays the following output:



Length of nums is 10

Here is nums: 0 1 4 9 16 25 36 49 64 81

In

LengthDemo

 notice the way that 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   206   207   208   209   210   211   212   213   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish