Jump to content
  • Advertisement
Sign in to follow this  
TheScriptan

Help with passing string

This topic is 2153 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i have made program that changes username nick in the main menu, but it wont work, here is the code

public void rUsername() 
    {
        string uInput;
        Console.WriteLine("Rename Your Username: ");
        uInput = Console.ReadLine();
        username = uInput;
        Console.Clear();
        Console.WriteLine("You changed your username succesfully! Press Enter To Continue...");
        Console.ReadLine();
        Console.Clear();
        initOptions();
    }

btw in class Options i have variable public string username; So what i want to do is just from this function pass it to the username that is in class, why it is not working (No Errors  btw)

Share this post


Link to post
Share on other sites
Advertisement

Why not do:

username = Console.ReadLine();

Or even:

string username;
cin >> username;
cout << username;

Besides I dont see you calling or passing your variable 'username' into your class.

Share this post


Link to post
Share on other sites

Dissipate, the OP's using C#, not C++.

The problem here is likely to be related to the 'username' variable somehow. TheScriptan, you need to give more information about how you create, access, and display that variable.

Share this post


Link to post
Share on other sites

How is it not working (what should be happening that is not, or what shouldn't be happening that is)? Is it not changing the name? Where does the username variable come from, and what is its value before this method is called (is it initialized)?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!