-1

I am sending a ref parameter; want to return an out parameter. Would I also need to create another method along with the ref method?

This is some context to what I am working on: "Create an internal static void method that receives degrees Celsius as a ref parameter and returns degrees Fahrenheit as an out parameter. There is no input or output in this method."

internal static void(ref int c, out int f){
f = c + 32;
return f;
} 
Aashna
  • 5
  • 2

1 Answers1

1

Two things wrong with your method - you are missing a method name, and you are returning a value when your method signature designates a void return type.

a third thing, although not a problem, is that there is no point declaring c as a ref parameter, since it is not being altered in your method.

internal static void convertCelciusToFahrenheit (ref int c, out int f){
    f = c + 32;
}

you also may want to check on your math to convert celsius to fahrenheit

pkatsourakis
  • 1,024
  • 7
  • 20
  • 1
    Why would you say that there's no point in declaring c as a `ref` parameter if it's explicitly requested in the task? " that receives degrees Celsius as a ref parameter" – Camilo Terevinto Feb 01 '19 at 01:10
  • 1
    i acknowledge that it's a part of the requested task, that's why it is in my solution. i just wanted to point out that it serves no practical purpose in this example. – pkatsourakis Feb 01 '19 at 01:15