Ошибки: Cannot implicitly convert type 'string' to 'int' и Argument 1: cannot convert from 'int' to 'string' - C#
Формулировка задачи:
youtube.com_Пишем парсер на Csharp. Ошибка
Пытаюсь написать парсер.
Вроде сделал всё как в уроке.
Выдаёт ошибки:
- в строке MessageBox.Show(GetNiks(1)); - ошибка: Argument 1: cannot convert from 'int' to 'string'
- в строке return nicks; - ошибка Cannot implicitly convert type 'string' to 'int'
Как устранить данные ошибки?
КОД
using xNet;
namespace rsh
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// ПАРСИНГ КОЛИЧЕСТВА СТРАНИЦ
//string s = Convert.ToString(GetCountPages());
//MessageBox.Show(s);
// ПАРСИНГ НИКОВ
// GetNiks(1);
// MessageBox.Show(Convert.ToString(GetNiks(1)));
MessageBox.Show(GetNiks(1));
}
// ПАРСИНГ НИКОВ
private int GetNiks(int Num) // int Num - это номер страницы с которой мы парсим ники
{
// string nicks = " ";
string nicks = "";
try
{
using (var Request = new HttpRequest())
{
string SourcePage; // перменная для хранения исходного кода страницы
string[] raw;
SourcePage = Request.Get("http://vegetarian.ru/forum/users/?PAGEN_1=" + Num).ToString(); // скачиваем исходный код страницы
// countPages = Convert.ToInt32(SourcePage.Substrings("/forum/users/?PAGEN_1=", "">", 0)[4]); // парсим количество стрниц. Применённая
raw = SourcePage.Substrings("title="">", "</a>", 0); // парсим количество стрниц. Применённая
// title = "">
// </a>
for (int i=0; i < raw.Length; i++)
{
if (i%2 == 0) // если дробная часть равна нулю
{
// MessageBox.Show(i + " " + raw[i]);
nicks += raw[i] + "\r\n";
}
}
}
}
catch
{
}
// return Convert.ToInt32(nicks);
return nicks;
}Решение задачи: «Ошибки: Cannot implicitly convert type 'string' to 'int' и Argument 1: cannot convert from 'int' to 'string'»
textual
Листинг программы
private string GetNiks(int Num)
{
...
}