Skip to main content
GameDev.net gamedev.net
🔒 Locked

Help with passing string

Started by TheScriptan Jan 22, 2013 at 2:41 PM 4 replies 2.2k views
Original Post
TheScriptan
TheScriptan

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 T
Dissipate
Dissipate

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.

Kylotan
Kylotan

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.

yewbie
yewbie

Does your initOptions();

Change the username variable back to the default?

Dissipate
Dissipate

Sorry... (tail_between_my_legs)*

InferiorOlive
InferiorOlive

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.