M
M
martensit2018-03-31 08:42:12
C++ / C#
martensit, 2018-03-31 08:42:12

How to create a method in C#?

string GETT(string Url)
{
return (url + "world");
}
return GETT("hi");
I'm trying to understand the correct creation of methods and their invocation.
What is missing dear?
I can't find an example anywhere to insert it into LINQPad 4 - and it works.
There are some mistakes everywhere.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2018-03-31
@martensit

First: I would recommend sticking to the naming conventions.
Secondly, please note that the Url argument is capitalized, and in the method itself you wrote it incorrectly. C# is a case sensitive language.

string Gett(string url) // ошибка с регистром была тут
{
     return (url + "world");
}

And finally: the line return GETT("hi"); I personally don't understand at all. If you want to call the GETT method, you don't need to use the return keyword. Or this line must be part of another method. Those. should it look like this
string Gett(string url)
{
     return (url + "world");
}
Gett("hi");  //вызывайте этот метод в функции Main

Or like this:
string Gett(string url)
{
     return (url + "world");
}

string SaySomething(string something)
{
     return Gett(something);
}

SaySomething("hi"); // вызывайте этот метод в Main

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question