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.

3
  • 6
    The warning will go away when you delete the line with the const variable. You don't use it anywhere anyway. Commented Oct 4, 2013 at 12:20
  • 3
    Use the variable or delete it.... Commented Oct 4, 2013 at 12:20
  • 4
    Comment out the line until you need it? Commented Oct 4, 2013 at 12:22

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

4 Comments

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.
@DarrenDavies It is up to him what should be done to it. But he is asking how to suppress it.
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.
Oh, I just realized that I wasn't even using the const. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.