Question there's no space between

bubbadk

New member
Joined
Mar 6, 2017
Messages
2
Programming Experience
Beginner
1.png

I'm trying to build my first app, this is just a test.

when im typing a first name and a surname there's no space between them when i hit the button.

can anyone help me :)

heres the code

String firstName;
string messageText;
string surName;
messageText = "Your name is: ";


//==========================
//=GET MESSAGE FROM TEXTBOX=
//==========================
firstName = forNavn.Text;
surName = efterNavn.Text;
//MessageBox.Show(messageText + firstName);
TextMessage.Text = messageText + firstName + surName;

2.PNG
 

Attachments

  • 1.JPG
    1.JPG
    21.6 KB · Views: 54
View attachment 305

I'm trying to build my first app, this is just a test.

when im typing a first name and a surname there's no space between them when i hit the button.

can anyone help me :)

heres the code

String firstName;
string messageText;
string surName;
messageText = "Your name is: ";


//==========================
//=GET MESSAGE FROM TEXTBOX=
//==========================
firstName = forNavn.Text;
surName = efterNavn.Text;
//MessageBox.Show(messageText + firstName);
TextMessage.Text = messageText + firstName + surName;

View attachment 306
Are you asking for us to confirm that there is no space between the first name and surname after you combine them? If so, yes, I can confirm there is no space and the code you posted also shows that when you concatenate the first name and surname values you are not adding a space to it.

If you're asking how to put a space between the first name and surname when you concatenate them, how would you suppose you would do that?
You can use a literal string in your code when concatenating it with a variable, eg you can:
var variable1 = "Some text";
var variable2 = variable1 + " here.";

MessageBox.Show(variable2);
 
ok i'm a complete newbie at this.

with the code i've written so far, how would my code look like with you'r suggestion. And can you explain what it does :)

thanks in advance :)
 
You obviously know how to concatenate multiple strings because you're already doing it. If you want to put a string with just a space in between those then just concatenate a string with a space in it between the ones you already have. Don't try to overcomplicate it. If you want a space then use a string containing a space.
 
Back
Top Bottom