Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ArrayofValues
- {
- class Program
- {
- static void Main(string[] args)
- {
- #region BytesExample
- byte[] bytes1 = new byte[100];
- Random rnd1 = new Random();
- rnd1.NextBytes(bytes1);
- Console.WriteLine("First Series:\n");
- for (int ctr = bytes1.GetLowerBound(0);
- ctr <= bytes1.GetUpperBound(0);
- ctr++)
- {
- Console.Write("{0,5}", bytes1[ctr]);
- if ((ctr + 1) % 10 == 0)
- {
- Console.WriteLine();
- }
- }
- #endregion
- LineDivider();
- #region Integer Example
- int[] numbers = new int[100];
- Random random = new Random();
- int min = 1;
- int max = 1000;
- Console.WriteLine("Example using integers:\n");
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(min, max - 1);
- Console.Write($"{numbers[i],5}");
- if ((i + 1) % 10 == 0)
- {
- Console.WriteLine();
- }
- }
- #endregion
- LineDivider();
- #region Example Using Chars
- //Instantiate new array to store data, and new Random class to generate random values
- char[] letters = new char[100];
- Random rand = new Random();
- //Define min and max values
- char minChar = 'A';
- char maxChar = 'Z';
- //Write Output to Console
- Console.WriteLine("Example using characters:\n");
- for (int i = 0; i < letters.Length; i++)
- {
- letters[i] = (char)rand.Next(minChar, maxChar - 1);
- Console.Write($"{letters[i],5}");
- ///<Summary>
- /// Each time though it checks to see if i is a factor of 10. If no it continues through loop writing to the current line.
- /// If yes, it writes a new line to write on.
- /// </Summary>
- if ((i + 1) % 10 == 0)
- {
- Console.WriteLine();
- }
- }
- Console.ReadLine();
- #endregion
- }
- public static void LineDivider()
- {
- Console.WriteLine("\n--------------------------------------------------\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement