Jump to content

  • Log In with Google      Sign In   
  • Create Account


Help with passing string


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 TheScriptan   Members   -  Reputation: 207

Like
0Likes
Like

Posted 22 January 2013 - 08:41 AM

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


Sponsor:

#2 Dissipate   Members   -  Reputation: 279

Like
0Likes
Like

Posted 22 January 2013 - 10:22 AM

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.



#3 Kylotan   Moderators   -  Reputation: 3329

Like
0Likes
Like

Posted 22 January 2013 - 10:49 AM

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.



#4 yewbie   GDNet+   -  Reputation: 665

Like
0Likes
Like

Posted 22 January 2013 - 11:07 AM

Does your initOptions();

Change the username variable back to the default?



#5 Dissipate   Members   -  Reputation: 279

Like
0Likes
Like

Posted 22 January 2013 - 11:11 AM

Sorry... (tail_between_my_legs)*



#6 NoAdmiral   Members   -  Reputation: 503

Like
0Likes
Like

Posted 22 January 2013 - 12:03 PM

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

 

herwrathmustbedragons.tumblr.com





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS