0

I've been making a text adventure game and I have these constants that contain the commands available to the players. For example:

const string ConScenChoiceOne = "hit monkey talk to monkey suicide go inside";
string conchoice1;  
Console.WriteLine("You arrive at a temple dedicated to the monkey god.");
Console.WriteLine("Outside is a monkey, presumably guarding the place.");
Console.WriteLine("What do you do?");  
Console.Write(">");  
conchoice1 = Console.ReadLine();  
if (conchoice1.Contains("hit monkey")) 

Is there any way to make the "variable not used" thing go away? I can't edit it since it's a constant.

Kamil Budziewski
  • 22,699
  • 14
  • 85
  • 105
Ilan
  • 513
  • 2
  • 8
  • 24

1 Answers1

1

You can suppress this warning :

1- By pargma

put this line at top of you class file:

#pragma warning disable 0169

2- By settings of your project

  1. In Solution Explorer, choose the project in which you want to suppress warnings.

  2. On the menu bar, choose View, Property Pages.

  3. Choose the Build page.

  4. In the Suppress warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons, and then rebuild the solution.

(your needed warning code is 0169)

Alireza
  • 10,237
  • 6
  • 43
  • 59
  • Although you can suppress warnings, why would you want to in this circumstance? The OP is not using the variable in the code, it's redundant so it can be removed. – Darren Oct 04 '13 at 12:23
  • @DarrenDavies It is up to him what should be done to it. But he is asking how to suppress it. – Alireza Oct 04 '13 at 12:24
  • 2
    he's asking how to make it go away. It is up to him what they do to get rid of the message, however the OP may not understand what the message actually means (i.e. does not realize that the variable is declared but never used). There is a better solution for this, in this case, remove the variable or comment it out until it's needed in code. – Darren Oct 04 '13 at 12:28
  • Oh, I just realized that I wasn't even using the const. Thanks! – Ilan Oct 04 '13 at 14:26