Question

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.

Was it helpful?

Solution

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top