Using System; using System.Collections.Generic; using System.Linq; using System.Text;...

0 голосов
102 просмотров

Using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Peregruzka test1 = new Peregruzka();
Peregruzka test2 = new Peregruzka();
Peregruzka test3 = new Peregruzka();
test1.method();
test2.method("Hello");
test3.method("Hello", "_World");
Console.WriteLine("Вызов методов: \n1){0} \n2){1} \n3){2}", test1.s, test2.s, test3.s);
TestStructura structura;
structura.x = 999;
structura.s = "Structura";
Console.WriteLine("x = {1}, s= {0}",
structura.s,structura.x);
Console.ReadKey();
}
}

class Peregruzka
{
public string s;
public string method()
{
return s = "Пусто";
}
public string method(string param1)
{
return s = param1;
}
public string method(string param1, string param2)
{
return s = param1 + param2;
}

}

public string method()
{
return s = param1;
}

struct TestStructura
{
public int x;
public string s;
}
}

Указывает ошибку в строке
public string method()
{
return s = param1;
}

Требуется класс делегат


Информатика (14 баллов) | 102 просмотров
Дан 1 ответ
0 голосов

Ошибка в том, что метод расположен в пространстве имен, а не в классе или структуре. Но даже если переместить его в класс Peregruzka, то всё равно будет ошибка, так как метод с такой сигнатурой уже есть. Решение - закомментировать этот метод (к тому же в нём есть ошибка). Решение во вложении.


Скачать вложение Текст (TXT)
(2.0k баллов)