In C#, when defining a public method like:
public int myMethod(String someString)
{
//code
}
What does the int indicate apart from the type integer? What confuses me is that the method is using a String as arguments in this case.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is the return type of the method. In this case a 32-bit signed integer with a range of
It corresponds to the .NET type
System.Int32.intis just a handy C# alias for it.You would return a value like this
And you could call it like this
If you do not need the return value, you can safely ignore it.
If you have no return value you would use the keyword
voidin place of the type.voidis not a real type.And you would call it like this
The method in your example accepts a
stringas input parameter and returns anintas result. A practical example would be a method that counts the number of vowels in astring.