Ajax
ASP
C,C++
C#,.NET
CSS,HTML
Delphi,Kylix
Experience
Flash
Java
JavaScript
PHP
Python
QT
SQL
ShellScript
VB
U :
P :
Register
Lost Password
Other Links
Code Archive
Save Giovanni
C#,.NET Category Code
Real Name
:
SharingCode.NET User
Subject
:
Creates and implements an instance of Array
Description
:
Creates and implements an instance of Array / örnek bir dizi oluşturma ve tamamlama
/* C# Programming Tips & Techniques by Charles Wright, Kris Jamsa Publisher: Osborne/McGraw-Hill (December 28, 2001) ISBN: 0072193794 */ // // CreatArr.cs -- Creates and implements an instance of Array // // Compile this program with the following command line: // C:>csc CreatArr.cs // namespace nsArray { using System; public class CreatArr { static public void Main () { DateTime now = DateTime.Now; Random rand = new Random ((int) now.Millisecond); // Create an instance of the Array class. Array Arr = Array.CreateInstance (typeof(Int32), 10); // Initialize the elements using the SetValue() member method // Use the GetLowerBound() and GetUpperBound() methods for safe access. for (int x = Arr.GetLowerBound(0); x < Arr.GetUpperBound(0) + 1; ++x) { Arr.SetValue (rand.Next () % 100, x); } int Total = 0; Console.Write ("Array values are "); // Use the foreach loop on the Array instance foreach (int val in Arr) { Total += val; Console.Write (val + ", "); } Console.WriteLine ("and the average is {0,0:F1}", (double) Total / (double) Arr.Length); } } }
Rating
:
0.00
(out of 5)
Visitor Voting Booth
:
Excellent
Very Good
Good
Fair
Poor
Copyright © 2006 SharingCode.NET . All rights reserved. Hosted By: SisNetworks