Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections;
- namespace ConsoleApp6
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- var FavoriteFood = new string[] { "Apple", "Cake", "Pizza", "Salad" };
- //поиск наиб числа среди целых чисел в arraylist
- //алгоритм: определять тип, то чето с ним делать
- // if p из тип - тру или фолс
- // cast преобразования: перед переменной (тип)
- Console.WriteLine("\n 2) ArrayList: ");
- ArrayList pos = new() { -1f, -2f, -3f, -5f, -6f, -11f};
- pos.AddRange(FavoriteFood);
- pos.Remove("Apple");
- pos.Remove("Salad");
- float max = float.MinValue;
- foreach (var p in pos)
- {
- if (p is float)
- {
- if ((float)p > max)
- {
- max = (float)p;
- }
- }
- }
- Console.Write(max);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement