Cannot implicitly convert type 'int' to 'int*'. An explicit conversion exists (are you missing a cast?) - C#

Узнай цену своей работы

Формулировка задачи:

Собственно вот код:
Листинг программы
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace ConsoleApplication3
  6. {
  7. class Program
  8. {
  9. unsafe
  10. static void Main()
  11. {
  12. List<int> spisok = new List<int>();
  13. Random r = new Random();
  14. for (int i = 0; i < 5; i++)
  15. spisok.Add(r.Next(1, 10));
  16. Console.WriteLine();
  17. foreach (int a in spisok)
  18. {
  19. Console.WriteLine(a);
  20. }
  21. Console.WriteLine("Ввод искомого");
  22. int b = Convert.ToInt32(Console.ReadLine());
  23. int l = spisok.Last();
  24. fixed (int* last = l)
  25. {
  26. if (b == last)
  27. {
  28. Console.WriteLine("Искомый элемент - последний в списке");
  29. }
  30. else
  31. {
  32. Console.WriteLine("Искомый элемент - не последний в списке.");
  33. }
  34. }
  35. Console.ReadKey();
  36. }
  37. }
  38. }
Ошибка в этом месте:
Листинг программы
  1. fixed (int* last = l)
Пишет: Cannot implicitly convert type 'int' to 'int*'. An explicit conversion exists (are you missing a cast?) Как исправить?

Решение задачи: «Cannot implicitly convert type 'int' to 'int*'. An explicit conversion exists (are you missing a cast?)»

textual
Листинг программы
  1. if (b == last)

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

9   голосов , оценка 3.556 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы