T
T
Tony13372017-04-20 19:11:09
C++ / C#
Tony1337, 2017-04-20 19:11:09

C# - How, when entering two words, assign a variable to the second word?

Hello! I am a beginner programmer. The other day I came across a problem: Let's say I have a variable 'a' - "Create". And then comes 'Console.ReadLine and if' (Well, not right away, this is just an example). And if a person enters a variable a (Create) and then he must press the spacebar and write what to create. For example: Create a button - and then a variable of the 'string' type is created and gets the value "button". Help, how can this be done? Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MrDywar Pichugin, 2017-04-20
@Tony1337

The question is not immediately clear.
1) You can use code examples immediately in the question, so it will "reach" faster.
2) Read the material - https://metanit.com/sharp/.
ReadLine reads a line, everything that is entered with a space and will be on one line separated by a space. The entry will be terminated by pressing Enter.
If you need to split words in a sentence, then do it using the space separator String.Split .
stackoverflow.com/questions/6111298/best-way-to-sp...

E
Eugene, 2017-04-20
@GoldGoblin

Do you want to create 1 more variable from the working program that did not exist earlier in the code? That's not possible. You can use objects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question