Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

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: 117

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)


Project Download Link: http://www.mediafire...zjahgz0b4ba70ep 0.01a Version!

My Project VCOS: http://www.gamedev.n...os-development/

0.01b is coming with much more updates! Check My Blog for TODO list :)

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


Sponsor:

#2 Dissipate   Members   -  Reputation: 184

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: 2987

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: 631

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: 184

Like
0Likes
Like

Posted 22 January 2013 - 11:11 AM

Sorry... (tail_between_my_legs)*



#6 NoAdmiral   Members   -  Reputation: 325

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






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