Cannot implicitly convert type 'int' to 'int*'. An explicit conversion exists (are you missing a cast?) - C#
Формулировка задачи:
Собственно вот код:
Ошибка в этом месте:
Пишет: Cannot implicitly convert type 'int' to 'int*'. An explicit conversion exists (are you missing a cast?)
Как исправить?
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication3
- {
- class Program
- {
- unsafe
- static void Main()
- {
- List<int> spisok = new List<int>();
- Random r = new Random();
- for (int i = 0; i < 5; i++)
- spisok.Add(r.Next(1, 10));
- Console.WriteLine();
- foreach (int a in spisok)
- {
- Console.WriteLine(a);
- }
- Console.WriteLine("Ввод искомого");
- int b = Convert.ToInt32(Console.ReadLine());
- int l = spisok.Last();
- fixed (int* last = l)
- {
- if (b == last)
- {
- Console.WriteLine("Искомый элемент - последний в списке");
- }
- else
- {
- Console.WriteLine("Искомый элемент - не последний в списке.");
- }
- }
- Console.ReadKey();
- }
- }
- }
Листинг программы
- fixed (int* last = l)
Решение задачи: «Cannot implicitly convert type 'int' to 'int*'. An explicit conversion exists (are you missing a cast?)»
textual
Листинг программы
- if (b == last)
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д