Interpolate C # 6 strings

1

I am interpolating strings and at the end of the line of code when I put the ; it gives me a message ( Empty statement is redundant ), but it still compiles the code, I show image.

The code is as follows:

static void FillTheseValues(out int a, out string b, out bool c)
{
    a = 9;
    b = "Enjoy your string.";
    c = true;
}
Console.WriteLine("***** Fun with Methods *****");
int i;
string str;
bool b;
FillTheseValues(out i, out str, out b);
Console.WriteLine($"Int is: {i}");
Console.WriteLine($"String is: {str}");

By the way, I'm using Visual Studio 2015 , I have ReSharper installed.

    
asked by Pedro Ávila 03.10.2016 в 22:50
source

2 answers

0

Well, it might be the ReSharper that is giving those% inexplicable warnings try to restart this

Herramientas -> Opciones 
-> ReSharper ->Suspender y Resume otra vez (sin necesidad de cerrar la ventana)  
(Si no funciona reinicie Visual Studio)

or try to format it like this, (its equivalent)

/*Console.WriteLine($"Int is: {i}");*/
 Console.WriteLine(string.Format("Int is {0}", i));
/*Console.WriteLine($"String is: {str}");*/
  Console.WriteLine(string.Format("String is {0}", str));
    
answered by 03.10.2016 / 23:37
source
-1

To avoid this warning, you should initialize the variable str to at least an empty string.

string str = string.Empty;
    
answered by 03.10.2016 в 23:20