Help with passing string

Started by
4 comments, last by InferiorOlive 11 years, 2 months ago

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)

Check out my blog or twitter for news how I am doing in the project "Learn Programming in 2 Years!". You can follow my progress, and help me! :)

My Projects:

"Learn Programming In 2 Years"

"Windows Tutorials"

"Ubuntu Tutorials"

My Games:

Moving@ IndieDB: http://www.indiedb.com/games/moving-rl

My Links:

My Blog: http://www.thescriptan.blogspot.com

My Twitter: https://twitter.com/TheScriptan

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.

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.

Does your initOptions();

Change the username variable back to the default?

Sorry... (tail_between_my_legs)*

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)?

Inspiration from my tea:

"Never wish life were easier. Wish that you were better" -Jim Rohn

soundcloud.com/herwrathmustbedragons

This topic is closed to new replies.

Advertisement